After jquery validation succeeds, the data is submitted using AJAX

Source: Internet
Author: User

1 function Checkform () {2Validator = $ ("#commentForm"). Validate ({//#formId为需要进行验证的表单ID3Errorelement:"span",//error marked with "div" tag, default: "Label", "Span" is displayed by default directly to the right of the text box4         //wrapper: "Li",//use the "Li" tab and wrap up the top errorelement.5         //errorclass: "Validate-error",//error prompt CSS class name "error"6         //Onsubmit:false,//whether to validate on form submission, default: True7         //Onfocusout:false,//whether to validate when the focus is taken, default: True8         //Onkeyup:false,//whether to verify when tapping the keyboard, default: True9         //Onclick:false,//whether to validate on mouse click (General validation Checkbox,radiobox)Ten         //Focuscleanup:false,//When the element that is not validated is focusable and the error is removed, the default false One         //Focusinvalid:true,//after a form is submitted, a form that does not pass validation (the first one or the unverified form that receives the focus before the submission) receives the focus, which is the default true A         //Ignore: "#cname"//Do not validate certain elements, values correspond to selectors, if you need to ignore multiple text boxes, you can use class selector -Ignoretitle:true, -Validclass:"valid",//when validation succeeds, the CSS class name used theSuccess:function (label) {//the prompt message to use when verifying success -Label.addclass ("valid"). HTML ("ok!") -            }, -Submithandler:function (form) {//If validation passes, click on the Submit button to perform the action, note: After using this method, the action= "xx" in the form will be invalidated +Alert'Validation by'); -         }, +Invalidhandler:function (Form, validator) {//if validation does not pass, perform additional operations here A               varErrors = Validator.numberofinvalids ();//get total number of errors at             varMessage ='you exist'+ Errors +'a mistake'; -             //alert (message); -         }, - rules:{ -             "X.name":{//input box that needs to be validated name -Requiredtrue,//verification Condition: Required inMinlength3:5,//validation Condition: Minimum length of 5 -Maxlength3:Ten, toCheckchartype: [true,false,false,NULL] +             }, -             "X.sex":{//input box that needs to be validated name theRequiredtrue,//verification Condition: Required *Minlength2:5,//validation Condition: Minimum length of 5 $Maxlength2:TenPanax Notoginseng             }, -         }, the messages:{ +             "X.name":{ ARequired:"cannot be empty", theMinLength:"the minimum value is 5" +             }, -             "X.sex":{ $Required:"cannot be empty", $MinLength:"the minimum value is 5" -             } -         } the     }); - }Wuyi  the function xx () { -     //Alert ($ ("#commentForm"). Validate (). form ());//performs form validation while judging whether validation passes, or False if passed by return true Wu$("#commentForm"). valid ();//$ ("#commentForm"). Valid () represents the form validation that runs the form - } About  $ function cl () { -$("#commentForm"). Validate (). Resetform ();//Clear all the error hints -}

Reprint to: http://blessht.iteye.com/blog/1074419

After jquery validation succeeds, the data is submitted using AJAX

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.