codeboy
2015-05-31 13:35
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>网页标题</title> <meta name="keywords" content="关键字列表" /> <meta name="description" content="网页描述" /> <link rel="stylesheet" type="text/css" href="" /> <style type="text/css"></style> </head> <body> <form id="demoForm" method='post'> <fieldset> <legend>用户登录</legend> <p> <label for="username">用户名</label> <input type="text" id="username" name="username"> </p> <p> <label for="password">密码</label> <input type="password" id="password" name="password"> </p> <p> <input type="submit" value="提交"> </p> </fieldset> </form> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.validate.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#demoForm").validate({ rules: { username:{ required:true, minlength:2, maxlength:10 }, password:{ required:true, minlength:2, maxlength:16 } } messages: { username:{ required:"用户名必须填写", minlength:"用户名最少为2字符", maxlength:"用户名最大为10字符" }, password:{ required:"密码必须填写", minlength:"密码最少为2字符", maxlength:"密码最大为16字符" } } }); }); </script> </body> </html>
46行少了一个逗号,亲测
你有引入 jquery.js 和jquery.validation.js 吗?
你检查一下你的语法,是中英文的问题不
46行少了一个逗号
jQuery插件——Validation Plugin
65871 学习 · 216 问题
相似问题