<script type="text/javascript" language="javascript">
    function RegisterSubmit(){  //进行表单的非空验证
        with (document.register){
            var user = loginname.value;
            var pass = password.value;
            if(user == null || user == ""){//要用或逻辑判断
                alert("用户名不能为空!");
            }else if(pass == null || pass == ""){//要用或逻辑判断
                alert("密码不能为空!");
            }else{
                document.register.submit();
            }
        }
    } 
</script>
</head>
<body>
<form name="register"  method="post" action="register.jsp"> 
    <table align="center" style="text-align:center" width="590" border="0">
        <tr>
            <td><p align="center">用户名:</p></td>
            <td align="left"><input type="text" name="loginname" size="20"></td>
        </tr>
        <tr rowspan="2">
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><p align="center">密&nbsp;码:</td>
            <td align="left"><input type="password" name="password" size="20"></td>
        </tr>
        <tr rowspan="2">
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><input type="button" value="提交" onClick="RegisterSubmit()"/></td>
            <td align="left"><input type="reset" value="重置" name="B2"/></td>
        </tr>
    </table>
</form>

解决方案 »

  1.   

     function RegisterSubmit(){  //进行表单的非空验证
            with (document.register){
                var user = loginname.value;
                var pass = password.value;
                if(user == null || user == ""){//要用或逻辑判断
                    alert("用户名不能为空!");
                }else if(pass == null || pass == ""){//要用或逻辑判断
                    alert("密码不能为空!");
                }else{
                    document.register.submit();
                }
            }
        } 
    正解。
      

  2.   

    额 没错 &&逻辑确实有些问题