• 前台校验


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            <form name="frm" method="post">
                <table>
                    <tr><td>用户名:</td><td><input type="text" name="" id="usernameId" value="" /></td><td><span id="userSpanId"></span></td></tr>
                    <tr><td>密码:</td><td><input type="password" name="" id="pwdId" value="" /></td><td><span id="pwdSpanId"></span></td></tr>
                    <tr><td>确认密码:</td><td><input type="password" name="" id="confPwdId" value="" /></td><td><span id="confPwdSpanId"></span></td></tr>
                    <tr><td><input type="button" onclick="check()" value="注册" /></td></tr>
                </table>
            </form>
            
            <script type="text/javascript">
                function check(){
                    var result1=checkUserName();
                    var result2=checkPwd();
                    var result3=checkTwoPwd();
                    
                    if(result1 && result2 && result3){
                        document.frm.action="RegisterServlet";
                        document.frm.submit();
                    }
                }
                
                function checkUserName(){
                    var uname=document.getElementById("usernameId");
                    var span=document.getElementById("userSpanId");
                    if(uname.value.trim().length==0){
                        span.innerHTML="<font color='red'>用户名不能为空啊!</font>";
                        return false;
                    }else{
                        span.innerHTML="√";
                        return true;
                    }
                }
                
                function checkPwd(){
                    var pwd=document.getElementById("pwdId");
                    var span=document.getElementById("pwdSpanId");
                    if(pwd.value.trim().length==0){
                        span.innerHTML="密码不能为空";
                        return false;
                    }else{
                        span.innerHTML="√";
                        return true;
                    }
                }
                
                function checkTwoPwd(){
                    var pwd=document.getElementById("pwdId");
                    var confPwd=document.getElementById("confPwdId");
                    
                    var pwdspan=document.getElementById("pwdSpanId");
                    var confpwdSpan=document.getElementById("confPwdSpanId");
                    
                    if(pwd.value==confPwd.value){
                        return true;
                    }else{
                        confpwdSpan.innerHTML="两次密码不一致";
                        
                        return false;
                    }
                }
                
            </script>
        </body>
    </html>
  • 相关阅读:
    Spring_Bean的配置方式
    Nginx Ingress设置账号密码
    2.2.4 加减运算与溢出
    2.2.5-2 补码乘法
    2.2.3 移位运算
    flask钩子函数
    flask的cookie、session
    循环冗余校验码
    海明校验码
    python中的 __call__()
  • 原文地址:https://www.cnblogs.com/tytr/p/5897098.html
Copyright © 2020-2023  润新知