JavaScript验证注册信息

<script language="javascript">
function check_login(form){
    if(form.username.value==""){
        alert("用户名不能为空");
        return(flase);
    }
    if(form.password.value==""){
        alert("密码不能为空");
        return(flase);
    }
    if(form.repwd.value==""){
        alert("确认密码不能为空");
        return(flase);
    }
    if(form.password.value!=form.repwd.value){
        alert("两次密码不一致");
        return(flase);
    }
    if(form.qq.value==""){
        alert("QQ号码不能为空");
        return(flase);
    }
    if(isNaN(form.qq.value)){
        alert("QQ格式不对");
    }
}
</script>
<form name="form" action="" method="post" onSubmit="return check_login(this)">
用户名<input type="text" name="username"><br>
密码:<input type="text" name="password"><br>
确认:<input type="text" name="repwd"><br>
qq:<input type="text" name="qq"><br>
<input type="submit" value="提交">
</form>
原文地址:https://www.cnblogs.com/BloodZero/p/4402092.html