利用正则判断用户邮件地址
类别: JavaScript教程
<html>
<script language="javascript">
function checkEmail(){
var reEmail = /^w[w-.]*w@([a-zd-]{2,}.)+[a-z]{2,}$/ig
if(frmUserInfo.txtEmail.value.match(reEmail)==null){
alert("This is an invalid e-mail address!")
}
else{
alert("This is an available e-mail address!")
}
}
</script>
<body>
<form name="frmUserInfo">
<input name="txtEmail" type="text" size="30" />
<input type="button" value="Check E-Mail" onclick="checkEmail()">
</form>
</body>
</html>
<script language="javascript">
function checkEmail(){
var reEmail = /^w[w-.]*w@([a-zd-]{2,}.)+[a-z]{2,}$/ig
if(frmUserInfo.txtEmail.value.match(reEmail)==null){
alert("This is an invalid e-mail address!")
}
else{
alert("This is an available e-mail address!")
}
}
</script>
<body>
<form name="frmUserInfo">
<input name="txtEmail" type="text" size="30" />
<input type="button" value="Check E-Mail" onclick="checkEmail()">
</form>
</body>
</html>
-= 资 源 教 程 =-
文 章 搜 索