用正则判断所输入的Email是否合法
<script language="Javascript">
<!--
function form1_onsubmit()
{s=document.form1.email.value
var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}.Net.Net|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
var re = new RegExp(regu);
if (s.search(re) != -1) {
return true;
} else {
window.alert ("请输入有效合法的E-mail地址 !")
return false;
}
}
-->
</script>
<form name="form1" >
your email:<input type="text" name="email"><br>
<input type="submit" name="submit" value="submit">
</form>
<!--
function form1_onsubmit()
{s=document.form1.email.value
var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}.Net.Net|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
var re = new RegExp(regu);
if (s.search(re) != -1) {
return true;
} else {
window.alert ("请输入有效合法的E-mail地址 !")
return false;
}
}
-->
</script>
<form name="form1" >
your email:<input type="text" name="email"><br>
<input type="submit" name="submit" value="submit">
</form>