|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>jQuery.validate</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script src="/demo/js/jquery-1.4.4.js"></script> <script type="text/javascript" src="/demo/js/jquery.validate.js"></script> <script type="text/javascript"><!-- $(document).ready(function(){ $("#test").validate({ rules:{//定义验证规则 pwd:{ required:true, minlength:5, maxlength:12 } }, messages:{//验证显示信息 name:"名字不能为空!", email:{ required:"邮箱地址必须填!", email:"邮箱地址格式不正确!" }, pwd:{ required:"密码不能为空!", minlength:jQuery.format("密码最少{0}位!"), maxlength:jQuery.format("密码最多{0}位!") } } }); });//--></script><style type="text/css"> body { font-size: 12px;}</style> </head> <body> <form action="" id="test" method="post"> <fieldset style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 6px 6px 6px 6px; width: 550px;margin: 0px;"> <legend style="font-size:14px;border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;"> jQuery.validate Demo </legend> <table> <tr> <td align="right"> <label> name: </label> </td> <td> <input style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;width: 150px;" class="required" name="name"> </td> </tr> <tr> <td align="right"> <label> email: </label> </td> <td> <input style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;width: 150px;" class="email required" name="email"> </td> </tr> <tr> <td align="right"> <label> password: </label> </td> <td> <input type="password" style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;width: 150px;" class="required" name="pwd"> </td> </tr> <tr> <td align="right"> &nbsp; </td> <td> <input style="border: 1px solid black; background-color: #AED0EA; -moz-border-radius: 3px 3px 3px 3px; font-weight: bold; color: black;" class="submit" type="submit" value="submit"> </td> </tr> </table> </fieldset> </form> </body></html> |
|