当前位置: 代码迷 >> J2EE >> jquery初学者问点验证提交有关问题
  详细解决方案

jquery初学者问点验证提交有关问题

热度:19   发布时间:2016-04-22 01:24:56.0
jquery菜鸟问点验证提交问题
JScript code
这里是引入        <title>会员的注册!</title>        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">        <script language="javascript" src="js/common.js"></script>        <script language="javascript" src="js/prototype.js"></script>        <script language="javascript" src="js/passwordstrength.js"></script>        <style type="text/css">这里是javaScpipt代码...<script language="javascript">    var icon = '<img src="images/warning.gif" width="14" height="14" border="0" align="absmiddle">';    var ns = ["usr","pwd","repwd","eml","pho"];    function changeUsr(){        if($("checkBtn").disabled) $("checkBtn").disabled = false;            }    function checkUsr(s){                var ma = ["用户名(3-16位)!","用户名由数字、英文、下划线、中杠线组成!"];        if(!limitLen(s,3,16)){            showInfo("usr",ma[0]);            return false;        }        if(!hasAccountChar(s)){            showInfo("usr",ma[1]);            return false;        }        showInfo("usr");        return true;    }    function checkPwd(s){        var ma = ["密码(5-16位)!","密码不能包含中文或全角符号!","两次输入的密码不一致!"];        ps.update(s);        if(!limitLen(s,5,16)){            showInfo("pwd",ma[0]);            return false;        }        if(hasChineseChar(s)){            showInfo("pwd",ma[1]);            return false;        }        if(limitLen($F("repwdInput"),5,16)){            if(trim($F("repwdInput")) == trim(s)){                showInfo("pwd");                showInfo("repwd");                return true;            }else{                showInfo("pwd",ma[2]);                return false;            }        }        showInfo("pwd");        return true;    }    function checkPwd2(s){        var ma = ["确认密码(5-16位)!","密码不能包含中文或全角符号!","两次输入的密码不一致!"];        if(!limitLen(s,5,16)){            showInfo("repwd",ma[0]);            return false;        }        if(hasChineseChar(s)){            showInfo("repwd",ma[1]);            return false;        }        if(limitLen($F("pwdInput"),5,16)){            if(trim($F("pwdInput")) == trim(s)){                showInfo("pwd");                showInfo("repwd");                return true;            }else{                showInfo("repwd",ma[2]);                return false;            }        }        showInfo("repwd");        return true;    }    function checkEml(s){        var ma = ["请输入常用邮件!","邮件格式不正确!"];        if(s.length < 5){            showInfo("eml",ma[0]);            return false;        }        if(!isEmail(s)){            showInfo("eml",ma[1]);            return false;        }        showInfo("eml");        return true;    }    function checkqq(s){        var ma = ["亲!输入大于五位内的数字号码","qq格式正确!"];        if(s.length < 5){            showInfo("qq",ma[0]);            return false;        }        if(!isqq(s)){            showInfo("qq",ma[0]);            return false;        }        showInfo("qq");        return true;    }        function checkpho(s){        var ma = ["手机号码错误","格式正确!"];        if(s.length < 5){            showInfo("pho",ma[0]);            return false;        }        if(s.length > 11){            showInfo("pho",ma[0]);            return false;        }        if(!isNaNPhone(s)){            showInfo("pho",ma[0]);            return false;        }        showInfo("pho");        return true;    }    function checkname(s){        var ma = ["请输入纯中文名字","名字格式正确!"];        if(!isChinese(s)){            showInfo("name",ma[0]);            return false;        }        showInfo("name");        return true;    }    function showInfo(n,s){        var fdo = $(n+"FrameDiv");        var ido = $(n+"InfoDiv");        if(typeof s == 'undefined'){            fdo.className = "FrameDivPass";            ido.innerHTML = "填写正确!";        }else{            fdo.className = "FrameDivWarn";            ido.innerHTML = icon + s;        }    }下面是html</head>    <body onLoad="initPage();">        <form action="MemberServlet" id="signupForm" method="post" onsubmit="return check();" >            <input type="hidden" name="method" value="reg">            <table width="100%" border="0" cellpadding="5" cellspacing="1"                bgcolor="#CCCCCC">                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        中文姓名                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="nameFrameDiv">                            <input name="name" type="text" id="name"                                onFocus="checkname(this.value);"                                onKeyUp="checkname(this.value);" maxlength="100">                            <div id="nameInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th width="20%" bgcolor="#EEEEEE" scope="row">                        用户名                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="usrFrameDiv">                            <input name="usrInput" type="text" id="usrInput" maxlength="16"                                onKeyUp="checkUsr(this.value);changeUsr();"                                onFocus="checkUsr(this.value);">                            <div id="usrInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        &nbsp;                    </th>                    <td bgcolor="#FFFFFF">                        <input name="checkBtn" type="button" id="checkBtn"                            onClick="loadCheck();" value="检测用户名是否可用">                        <div id="checkDiv"></div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        密码强度                    </th>                    <td bgcolor="#FFFFFF">                        <script language="javascript">        var ps = new PasswordStrength();        ps.setSize("200","22");    </script>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        密码                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="pwdFrameDiv">                            <input name="pwdInput" type="password" id="pwdInput"                                maxlength="16" onKeyUp="checkPwd(this.value);"                                onFocus="checkPwd(this.value);">                            <div id="pwdInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        确认密码                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="repwdFrameDiv">                            <input name="repwdInput" type="password" id="repwdInput"                                maxlength="16" onKeyUp="checkPwd2(this.value);"                                onFocus="checkPwd2(this.value);">                            <div id="repwdInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        QQ                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="qqFrameDiv">                            <input name="qq" type="text" id="qq"                                onFocus="checkqq(this.value);" onKeyUp="checkqq(this.value);"                                maxlength="11">                            <div id="qqInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        EMail                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="emlFrameDiv">                            <input name="emlInput" type="text" id="emlInput"                                onFocus="checkEml(this.value);" onKeyUp="checkEml(this.value);"                                maxlength="40">                            <div id="emlInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        手机号码                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="phoFrameDiv">                            <input name="phoInput" type="text" id="phoInput"                                onFocus="checkpho(this.value);" onKeyUp="checkpho(this.value);"                                maxlength="40">                            <div id="phoInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        地址                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="addFrameDiv">                            <input type="text" name="address" id="address" size="60"                                maxlength="100" />                            <div id="addInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        描述                    </th>                    <td bgcolor="#FFFFFF">                        <div class="FrameDivNormal" id="desFrameDiv">                            <textarea rows="5" cols="70" name="description" id="description"></textarea>                            <div id="desInfoDiv"></div>                        </div>                    </td>                </tr>                <tr>                    <th bgcolor="#EEEEEE" scope="row">                        &nbsp;                    </th>                    <td bgcolor="#FFFFFF">                        <input type="submit" name="submit" id="submit" value="提交">                    </td>                </tr>            </table>        </form>    </body></html>
  相关解决方案