jquery 表单验证插件validation(国际化)的使用

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
 <script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
 <script src="lib/jquery.validate.js" type="text/javascript"></script>
  <script type="text/javascript">
      $(function() {
          $('#commentForm').validate({
              rules: {
                  username: { required: true, minlength: 2 },
                  email: { required: true, email: true },
                  url: { url: true },
                  comment: { required: true }
              },
              messages: {
                  username: { required: '请输入姓名', minlength: '请至少输入两个字符' },
                  email: { required: '请输入电子邮件', email: '请检查电子邮件的格式' },
                  url: { url: '请检查网址的格式' },
                  comment: { required: '请输入您的评论' }
              }
          });
      });
  </script>
  
</head>
<body>
 
 <form class="cmxform" id="commentForm" method="get" action="">
 <fieldset>
   <legend>一个简单的验证带验证提示的评论例子</legend>
   <p>
     <label for="cusername">姓名</label>
     <em>*</em><input id="cusername" name="username" size="25" />
   </p>
   <p>
     <label for="cemail">电子邮件</label>
     <em>*</em><input id="cemail" name="email" size="25"  />
   </p>
   <p>
     <label for="curl">网址</label>
     <em>  </em><input id="curl" name="url" size="25"  value="" />
   </p>
   <p>
     <label for="ccomment">你的评论</label>
     <em>*</em><textarea id="ccomment" name="comment" cols="22" rows="2"></textarea>
   </p>
   <p>
     <input class="submit" type="submit" value="提交"/>
   </p>
 </fieldset>
 </form>
</body>
</html>
 

jquery.validate.js下载页面 http://download.csdn.net/detail/czh4869623/5777221

你可能感兴趣的:(jquery,validation)