方法很多
userPwd = document.form1.userPwd.value;
userPwd2 = document.form1.userPwd2.value;
if (userPwd2 != userPwd)
{
   alert("报错");
   return false;
}
else
{
   location = "xx.asp";
}

解决方案 »

  1.   

    我用的是ASP,<form name="registerarea" method="post" action="registersub.asp">,请问当密码不同,报错后,怎样使网页不转到registersub.asp上,而是停在当前页面上提示用户重新输入密码?
      

  2.   

    <script>
    <!--
    function checkForm(){
    userPwd = document.registerarea.userPwd.value;
    userPwd2 = document.registerarea.userPwd2.value;
       if (userPwd2 != userPwd)
          {      
           alert("密码不一致。");
            return false;
          }
    }
    //-->
    </script>
    <form name="registerarea" method="post" action="registersub.asp" onSubmit="return checkForm();"><input name="userPwd" type="password">
    <input name="userPwd2" type="password">
    <input type="submit" name="button" value="确定">
    </form>
      

  3.   

    如果有两个检查条件,即<script></script>中有两个function, 那么onsubmit怎么写?
      

  4.   

    回LS,有两个检查条件可以在一个function里检查嘛