<form name="form" action="#"><input type="password" id="pwd1" />
<input type="password" id="pwd2" />
<input type="submit" value="提交" onclick="return check()" />
</form>
<script>
   function  check(){
   var pwd1 = document.getElementById("pwd1").value;
   var pwd2 = document.getElementById("pwd2").value;
      if(pwd2!=pwd1){   //这里我只判断是否相等了 没做其他判断
           alert("两次输入的密码不一致,请检查!");
           return false;   //return false是用来阻止表单提交的 
      }
      return true;
   }
</script>
posted on 2018-01-14 12:42  SoftBlue  阅读(322)  评论(0编辑  收藏  举报