时间:2021-07-01 10:21:17 帮助过:6人阅读
<script type="text/javascript"> var sText = document.getElementById('mail').value; //onblur 为控件失去焦点事件 document.getElementById('mail').onblur = function sValue(){ sText = this.value; var reMail =/^(?:[a-zA-Z0-9]+[_\-\+\.]?)*[a-zA-Z0-9]+@(?:([a-zA-Z0-9]+[_\-]?)*[a-zA-Z0-9]+\.)+([a-zA-Z]{2,})+$/; var s=new RegExp(reMail); if(s.test(sText)) {alert("邮箱正确");} else//不正确清空 {document.getElementById('mail').value="";} } </script>