前端js验证正则

 <script>

function sendVerifyMail(){

var _url = global.basePath + "oth/find_password_mail.do";

var reg = new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$");

var email = $('#email').val();

if(email == ''){

dialogMessage("邮箱不能为空!");

return false;

}else if(!reg.test(email)){

dialogMessage("邮箱格式不正确,请重新输入!");

return false;

}else{

$.post(_url,{'email':email},function(result){

var obj = $.parseJSON(result);

dialogMessage(obj.message);

});

}

}

</script>
posted @ 2022-05-10 16:14  cmooc  阅读(34)  评论(0编辑  收藏  举报