Using the Metadata method
This requires the use of the Jquery.metadata.js plugin to work, specifying validation rules by defining special properties in the form item
However, the latest jquery.validate 1.11 does not have the built-in metadata support and needs to be modified code:
function (Element) { ifreturn {}; var meta = $.data (element.form, "validator"). Settings.meta; return meta? $ (Element). metadata () [meta]: $ (Element). metadata ();},
Here, the transformation is complete, to use metadata, the page uses the following methods (omitting other code):
<script src= "Lib/jquery.js" type= "Text/javascript" ></script> <script src= "Lib/jquery.metadata.js" Type= "Text/javascript" ></script><script src= "Lib/jquery.validate.js" type= "Text/javascript" ></ script><form> <input name= "user" class= "{required:true, minlength:3}"/></form>
However, the default class is used to define the CSS style class name, which is used as a validation rule to create too much inconvenience to the style maintenance, there are two ways to solve the problem:
A. Modifying jquery.metadata.js directly, type modified to attr, name modified to validate, indicating the validation rule obtained from the Validate property of the form item
B. Call $.metadata.settype (' attr ', ' Validate ') in the page header to obtain the validation rule from the Validate property of the form item
jquery.validata1.11 How to support metadata