<div class="codetitle"> <span><a style="CURSOR: pointer" data="97303" class="copybut" id="copybut97303" onclick="doCopy('code97303')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code97303"> <br> <br> <br> <br><title>jqueryValidateDemo</title> <br><script type="text/javascript" src="js/jquery.js"></script> <br><script type="text/javascript" src="js/jquery.validate.js"></script> <br><script type="text/javascript"> <BR>$(function() { <BR>$("#login").validate({ <BR>rules:{ <BR>name:{ <BR>required:true <BR>}, <BR>password:{ <BR>required:true, <BR>minlength:4 <BR>} <BR>}, <BR>messages:{ <BR>name:{ <BR>required:"此项为必填项" <BR>}, <BR>password:{ <BR>required:"此项为必填项", <BR>minlength:"密码长度至少为4个字符" <BR>} <BR>} <BR>}) <BR>}); <BR></script> <br> <br> <br><form action="" id="login" method="post"> <br><table align="center" border="1"> <br><tr> <br><td>登录名</td> <br><td><input type="text" id="name" name="name"></td> <br> </tr> <br><tr> <br><td>密码</td> <br><td><input type="password" id="password" name="password"></td> <br> </tr> <br><tr> <br><td align="center" colspan="2"><input type="submit" value="注册"></td> <br> </tr> <br> </table> <br> </form> <br> <br><br> </div>