JS-Jquery 同步校验两次密码是否相同

来源:互联网 发布:手机淘宝内部优惠券 编辑:程序博客网 时间:2024/06/05 15:41

模版简易代码


<li><input id="password" name="password" placeholder="请输入密码"  onfocus='passwd()'  type="password" class="free-input input-w-200 pass"  maxlength="32" /></li><li><input id="password1" name="password1" type="password"  class="free-input input-w-200 pass"  onkeyup='validate()' placeholder="请再次输入密码" value="" /><br><span id="tishi"></span></li>



js代码:


function validate() {    var pwd1 = document.getElementById("password").value;    var pwd2 = document.getElementById("password1").value;    if(pwd1 == pwd2) {        document.getElementById("tishi").innerHTML="<font color='gray'>输入正确</font>";/*         $("#tishi").hide(1500); */        document.getElementById("dosubmit").disabled = false;    }    else {      document.getElementById("tishi").innerHTML="<font color='red'>两次密码不相同</font>";      document.getElementById("dosubmit").disabled = true;    }}