两次密码输入是否一致(HTML)

  • Post author:
  • Post category:其他




两次密码输入是否一致

<div class="zhuce_body">
    <div class="zhuce_kong">
      <div class="zc">
          <div class="bj_bai">
            <h3>欢迎注册</h3>
              <form action="${pageContext.request.contextPath}/UserRegisterServlet?op=register" method="post">
                <input name="password" id="pw" type="password" class="kuang_txt possword" placeholder="密码(不少于6位)" >
                <input name="repassword" id="repw" type="password" class="kuang_txt possword" placeholder="确认密码" onkeyup="checkpassword()">
                <span id="tishi"></span></input>
                <input name="注册" type="submit" class="btn_zhuce" value="注册">
                
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
      function checkpassword() {
        var password = document.getElementById("pw").value;
        var repassword = document.getElementById("repw").value;
        
        if(password == repassword) {
           document.getElementById("tishi").innerHTML="<br><font color='green'>两次密码输入一致</font>";
           document.getElementById("submit").disabled = false;
          
       }else{
         document.getElementById("tishi").innerHTML="<br><font color='red'>两次输入密码不一致!</font>";
           document.getElementById("submit").disabled = true; 
       }
      }
    </script>



版权声明:本文为qq_46201532原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。