After validation in the jquery validation, the custom submits a different action path, suitable for a window that can either be added as a dialog box or as an Edit dialog box

Source: Internet
Author: User

$ ("#myform"). Validate ({debug:true,//Debug mode cancels the default submit feature for SubmitIgnore: ' #Password, #ConfirmPassword ', Focusinvalid:false,                //---------------------------------------------------------------------------Submithandler:function() {//form submission handle, as a callback function                    varSubmitway = $ ("#submitbtn"). text (); if(Submitway = = "Edit Save")                        varGeturl = "/membership/update"; Else if(Submitway = = "Add Save")                        varGeturl = "/membership/add"; varOptions ={type:"POST", Url:geturl, DataType:"JSON", Data: $ ("#myform"). Serialize (), Success:function(data) {if(data.success) {alert (data.messages); $("#AddMembership"). Modal (' Hide ');                            Window.parent.location.reload (); }                            Elsealert (data.messages);                    }                    };                    $.ajax (options); return false; },                //---------------------------------------------------------------------------                                  rules: {' Email ': {required:true, Email:true                    },                    ' UserName ': {required:true, Stringcheck:true, minlength:3, MaxLength:20                    },                    ' Mobile ':{                        //required:true,//With no sentence to indicate that this item does not fill also can, if fill in will check fill in the RulesIsMobile:true                    },                    ' Password ': {required:true, minlength:6, MaxLength:20                    },                    ' ConfirmPassword ': {required:true, minlength:6, Equalto:"#Password"                    },                    ' RoleName ': {required:true                    },                    ' IsApproved ': {required:true                    },                    ' Gender ': {required:true}}, messages: {UserName: { Required:"Please fill in User name", Stringcheck:"User name can only include Chinese characters, English letters, numbers, and underscores", minlength:"User name must be between 3-20 characters (2 characters in one text)"                    },                    ///email: "Please enter your email address. ",password:{required: "Please enter your password", minlength: "Password must be at least 6 characters or more!" "}                }            });

Applicable version: Jquery-1.8.3.min.js, jquery-2.0.3.min.js

After validation in jquery validation, custom commits different action paths, suitable for a window that can either be added as a dialog box or as an Edit dialog box

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.