jquery Validate Plugin Usage tips

Source: Internet
Author: User
$ ("form"). Validate ({              debug:true,   //debug mode (form not submitted)                 rules:{                  name:{  //custom rules, Key:value form, Key is the element to be validated, value can be a string or object                         //built-in verification method                      required:true, //Required Fields                          required: "#aa: Checked",//the value of the expression is true, required                         required:function () {},//return to true, required fields                          email:true,   //verifying e-mail format                         minlength:5,  //Set Minimum Length                          maxlength:10, //set Maximum length                         rangelength:[5,10],//setting a length range [Min,max]                         min:2,        //Set minimum                          max:8,        //set maximum value                         range:[2,8]      //setting the range of values                         url:true,         //Verify URL format                         date:true,    //Verify date format (similar to 30/30/2008 format, do not verify date accuracy only validation format)                          dateiso:true, //Verifying the date format of the ISO type   For example:2009-06-23                        datede:true,  // Verify the German-style date format (29.04.1994  or 1.1.2006)                         number:true,  //Verifying decimal digits (including decimals)                          digits:true,  //Verifying integers                         creditcard:true, //Verifying credit card numbers                          Accept: ""      //enter a string with a legal suffix (the suffix of the uploaded file)                         equalto: "ID Name"  / /Verify that the contents of the two input boxes are the same                         phoneus:true   //Verifying American phone numbers
Using AJAX to authenticate, the default is to submit the current validated value to the remote address, if you need to commit additional values, you can use the data option background only allowed to return false and True
Remote: "check-email.php"
Remote: {
URL: "check-email.php",//Background handler
Type: "POST",//Data sending method
DataType: "JSON",//Accept data format
Data: {//To be passed
Username:function () {
Return $ ("#username"). Val ();
}
                   }          &nbsp ;           }                },                   messages:{                    name: "Name cannot be empty",   //a custom hint information key:value form key is the element to be validated, the value is a string or function                },                   errorplacement: function (error,element)  {                    //Error Display location  element validated element error warning                },                   submithandler:function (form)  {//function that is run after validation, which is added to the form submission function, otherwise the form will not be submitted                 },                   success: "Class name",   //the element to validate passes the validated action, followed by a string that appends a CSS class to the element that is outputting the error             success:function (Element) {},   //The element to validate passes the validated action, followed by a callback function, Element represents the             ignore that holds the current validation element: ". Ignore"  //do not validate certain elements                onsubmit : false   //is submitted with validation   default:true                onfocusout:false //whether to validate   default:true    when getting focus              onkeyup:false    //Verify   Default:true   when tapping the keyboard              onclick:false    // Whether to validate on mouse click (General validation Checkbox,radiobox)   default:true                focusinvalid:false //a form that has not been validated after the form is submitted (the first one or the unverified form that received the focus before submission) gets focus   default: True                focusCleanup:true   //when the element that is not validated has the focus, and the error prompt is removed (avoid and  focusinvalid.) Default:false                errorclass: "Class name"   //the CSS class name that specifies the error hint, you can customize the style of the error prompt   default: " Error "               errorelement:" Tag "  //what tags to use tag error   default: "Label"                 wrapper: "Tags"       //what label to use and then wrap up the top errorelement                 errorlabelcontainer: "Container id"   //put the error message in a container                 showerrors:function (errorMap,errorList)  {  //with a function that shows the total number of failed validation elements                     $ ("#summary"). HTML ("your form contains "  +  This.numberofinvalids ()  +  " errors,see details below.");                     This.defaultshowerrors ();               }     errorClass:  "class name", 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.