$(".login-btn").on("click", function () {
return check()
})
function check() {
var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); //正则表达式
var userName = document.getElementById("userName").value; //要验证的对象
var userPwd = document.getElementById("userPwd").value; //要验证的对象
if (userName == "") { //输入不能为空
alert("用户名不能为空!");
return false;
} else if (!reg.test(userName)) { //正则验证不通过,格式不对
alert("验证不通过!");
return false;
} else {
alert("通过!");
return true;
}
if (userPwd == "") {//输入不能为空
alert("密码不能为空!");
return false;
} else {
alert("通过!");
return true;
}
}
780

被折叠的 条评论
为什么被折叠?



