Home > Web Front-end > JS Tutorial > body text

jquery.validate.js Detailed explanation of how to handle multiple identical names

小云云
Release: 2018-01-01 10:57:48
Original
1801 people have browsed it

This article introduces you to the jquery.validate.js processing method of multiple identical names through code. It is very good and has reference value. Friends who need it can refer to it. I hope it can help everyone.

1. Plug-in to be introduced: jquery.validate.js Code comment on line 484:


// select only the first element for each name, and only those with rules specified
  //if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) { return false; }
Copy after login

2. Input box that needs to be verified on the page A different id must be added.

For example: in html:


##

<form>
  <input type=&#39;text&#39; name=&#39;name&#39; id=&#39;name1&#39; val=&#39;&#39;/>
  <input type=&#39;text&#39; name=&#39;name&#39; id=&#39;name2&#39; val=&#39;&#39;/>
</form>
Copy after login

js:


 var $form=$(&#39;form&#39;),validator=$form.validate();
  $.extend(validator.settings,{
    rules:{
      "name":&#39;required&#39;
    }
  });
Copy after login
Related recommendations:


Solution to the problem of using jQuery to dynamically operate name in IE7

Detailed example of node.js using fs.rename to force rename or move a folder

Use the name attribute of html to get the dom element

The above is the detailed content of jquery.validate.js Detailed explanation of how to handle multiple identical names. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template