密码的修改标签:新密码,return,pwd1,修改,密码,getElementById,msg,document,2.13 From: https://www.cnblogs.com/dmx-03/p/18040219
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>新密码</title> </head> <body> <div style="text-align: center"> <form action="updatepwd_servlet" method="post" id="change_pwd"> 账号:<input type="text" value="${code}" name="nameid" readonly><br> <label for="pwd1">请输入新密码:</label><input type="password" name="pwd" id="pwd1"><br> <label for="pwd1">再次确认密码:</label><input type="password" name="p" id="pwd2"><br> <span id="msg" style="font-size: 12px;color:red">${msg}</span><br><br> <button type="button" id="btm">确认</button> </form> <script> document.getElementById("btm").addEventListener("click",function () { var pwd1=document.getElementById("pwd1").value; var pwd2=document.getElementById("pwd2").value; if(!is(pwd1)) { document.getElementById('msg').innerHTML="您的新密码不能为空"; return; } if(!is(pwd2)) { document.getElementById('msg').innerHTML="您再次确认密码不能为空"; return; } if(pwd1.length>20) { document.getElementById('msg').innerHTML="您的新密码长度超过限制"; return; } if(pwd1!==pwd2) { document.getElementById('msg').innerHTML="您的两次密码输入不一致"; return; } document.getElementById("change_pwd").submit(); }) function is(s) { if (s.length===0||s.trim()==="") return false; else return true; } </script> </div> </body> </html>