jQuery校验 validate

论坛 期权论坛     
选择匿名的用户   2021-5-30 00:14   164   0
<div class="blogpost-body" id="cnblogs_post_body">
<p>官网地址:<a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">http://bassistance.de/jquery-plugins/jquery-plugin-validation</a></p>
<h2><span style="font-family:&#39;黑体&#39;;">一导入</span><span lang="en-us">js</span><span style="font-family:&#39;黑体&#39;;">库</span></h2>
<p align="left" style="text-align:left;"><span lang="en-us" style="font-family:&#39;宋体&#39;;font-size:12pt;">&lt;script src&#61;&#34;../js/jquery.js&#34; type&#61;&#34;text/javascript&#34;&gt;&lt;/script&gt;<br>&lt;script src&#61;&#34;../js/jquery.validate.js&#34; type&#61;&#34;text/javascript&#34;&gt;&lt;/script&gt;</span></p>
<h2><span style="font-family:&#39;黑体&#39;;">二、默认校验规则</span></h2>
<p align="left" style="text-align:left;"><span lang="en-us" style="font-family:&#39;宋体&#39;;font-size:12pt;">(1)required:true              </span> <span style="font-family:&#39;宋体&#39;;font-size:12pt;">必输字段<span lang="en-us"><br>(2)remote:&#34;check.php&#34;         </span> 使用<span lang="en-us">ajax</span>方法调用<span lang="en-us">check.php</span>验证输入值<span lang="en-us"><br>(3)email:true                 </span> 必须输入正确格式的电子邮件<span lang="en-us"><br>(4)url:true                   </span> 必须输入正确格式的网址<span lang="en-us"><br>(5)date:true                  </span> 必须输入正确格式的日期 日期校验<span lang="en-us">ie6</span>出错,慎用<span lang="en-us"><br>(6)dateISO:true               </span> 必须输入正确格式的日期<span lang="en-us">(ISO)</span>,例如:<span lang="en-us">2009-06-23</span>,<span lang="en-us">1998/01/22</span> 只验证格式,不验证有效性<span lang="en-us"><br>(7)number:true                </span> 必须输入合法的数字<span lang="en-us">(</span>负数,小数<span lang="en-us">)<br>(8)digits:true                </span> 必须输入整数<span lang="en-us"><br>(9)creditcard:                </span> 必须输入合法的信用卡号<span lang="en-us"><br>(10)equalTo:&#34;#field&#34;          </span> 输入值必须和<span lang="en-us">#field</span>相同<span lang="en-us"><br>(11)accept:                   </span> 输入拥有合法后缀名的字符串(上传文件的后缀)<span lang="en-us"><br>(12)maxlength:5               </span> 输入长度最多是<span lang="en-us">5</span>的字符串<span lang="en-us">(</span>汉字算一个字符<span lang="en-us">)<br>(13)minlength:10              </span> 输入长度最小是<span lang="en-us">10</span>的字符串<span lang="en-us">(</span>汉字算一个字符<span lang="en-us">)<br>(14)rangelength:[5,10]        </span> 输入长度必须介于 <span lang="en-us">5</span> 和 <span lang="en-us">10</span> 之间的字符串<span lang="en-us">&#34;)(</span>汉字算一个字符<span lang="en-us">)<br>(15)range:[5,10]              </span> 输入值必须介于 <span lang="en-us">5</span> 和 <span lang="en-us">10</span> 之间<span lang="en-us"><br>(16)max:5                     </span> 输入值不能大于<span lang="en-us">5<br>(17)min:10                    </span> 输入值不能小于<span lang="en-us"><span lang="en-us">10</span></span></span></p>
<p align="left" style="text-align:left;"> </p>
<h2><span style="font-family:&#39;黑体&#39;;">三、默认的提示</span></h2>
<p align="left" style="text-align:left;"> </p>
<p align="left" style="text-align:left;"><span lang="en-us" style="font-family:&#39;宋体&#39;;font-size:12pt;">messages: {<!-- --><br>    required: &#34;This field is required.&#34;,<br>    remote: &#34;Please fix this field.&#34;,<br>    email: &#34;Please enter a valid email address.&#34;,<br>    url: &#34;Please enter a valid URL.&#34;,<br>    date: &#34;Please enter a valid date.&#34;,<br>    dateISO: &#34;Please enter a valid date (ISO).&#34;,<br>    dateDE: &#34;Bitte geben Sie ein g</span><span style="font-family:&#39;宋体&#39;;font-size:12pt;">眉<span lang="en-us">ltiges Datum ein.&#34;,<br>    number: &#34;Please enter a valid number.&#34;,<br>    numberDE: &#34;Bitte geben Sie eine Nummer ein.&#34;,<br>    digits: &#34;Please enter only digits&#34;,<br>    creditcard: &#34;Please enter a valid credit card number.&#34;,<br>    equalTo: &#34;Please enter the same value again.&#34;,<br>    accept: &#34;Please enter a value with a valid extension.&#34;,<br>    maxlength: $.validator.format(&#34;Please enter no more than {0} characters.&#34;),<br>    minlength: $.validator.format(&#34;Please enter at least {0} characters.&#34;),<br>    rangelength: $.validator.format(&#34;Please enter a value between {0} and {1} characters long.&#34;),<br>    range: $.validator.format(&#34;Please enter a value between {0} and {1}.&#34;),<br>    max: $.validator.format(&#34;Please enter a value less than or equal to {0}.&#34;),<br>    min: $.validator.format(&#34;Please enter a value greater than or equal to {0}.&#34;)<br>},</span></span></p>
<p align="left" style="text-align:left;"> </p>
<p align="left" style="text-align:left;"><span style="font-family:&#39;宋体&#39;;font-size:12pt;">如需要修改,可在<span lang="en-us">js</span>代码中加入:</span></p>
<p align="left" style="text-align:left;"> </p>
<p align="left" style="text-align:left;"><span lang="en-us" style="font-family:&#39;宋体&#39;;font-size:12pt;">$.extend(<span lang="en-us" s
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP