JavaScript判断E-mail地址是否合法

时间:2022-09-24 09:08:37
编写自定义的JavaScript函数checkEmail(),在该函数中首先判断E-mail文本框是否为空,然后在应用正则表达式判断E-mail地址是否合法,如果不合法提示用户
<script type="text/javascript">  		function checkEmail(){  	  		var email = document.getElementById("email");			if(email.value == null || email.value == ""){				alert("请输入E-mail地址!");				email.focus();				return;			}			var regExp = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;			if(!regExp.test(email.value)){				alert("您输入的E-mail地址不正确!");				email.focus();				return;			}  	  	}  	</script><span style="white-space:pre">