27
2021
11

原生js判断表单是否填写,两次密码是否相同

if (document.form1.hy_user.value == ""){

layer.open({

content: '手机号码必须正确输入'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_user.focus();

return (false);//停止往下运行

};

var hy_user = document.form1.hy_user.value 

if(!(/^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/.test(hy_user))){

layer.open({

content: '手机号码格式不正确'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_user.focus();

return false;

};

if (document.form1.hy_user.value.length<11){

layer.open({

content: '手机号码不足11位'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_user.focus();

return (false);

};

if (document.form1.hy_pwd.value.length<6){

layer.open({

content: '密码不能小于6位'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_pwd.focus();

return (false);

};

if (document.form1.hy_pwd2.value == "")

{

layer.open({

content: '密码必须输入'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_pwd2.focus();

return (false);

};

var hy_pwd = document.form1.hy_pwd.value;

    var hy_pwd2 = document.form1.hy_pwd2.value;

if(hy_pwd != hy_pwd2){

layer.open({

content: '两次密码不同'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_pwd2.focus();

return false;

}

if (document.form1.hy_name.value == "")

{

layer.open({

content: '门店名称必须输入'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_name.focus();

return (false);

};

if (document.form1.hy_add.value == "")

{

layer.open({

content: '门店地址必须输入'

,skin: 'msg'

,time: 2 //2秒后自动关闭

});

document.form1.hy_add.focus();

return (false);

};

};


« 上一篇下一篇 »