Normal forms are submitted using the Submit button, and the jquery Validate plugin makes it easy to do forms validation.
To do a text messaging function, to the target table to insert multiple records, the interface using AJAX to submit the form, waiting for the effect directly with the Ext mask.
But how to verify and run into problems.
The solution is simple, the form is the same as the normal form, the validate of the Submithandler,invalidhandler 2 methods need to overwrite, all return false, so that the form will not be submitted when the button click, form validation and normal validation work. Submithandler write our form processing code before the return is OK.
The code below, you can ignore ext related code.
1 //Form Validation2$ ("#query"). Validate ({3OnKeyUp:false,4OnClick:false,5Onfocusout:false,6 rules: {7 msg: {8Required:true,9Maxlength:10Ten } One }, A messages:{ - msg:{ -Required: ' Please input SMS content! ', theMaxLength: ' Longer than 10! ' - } - }, -ShowErrors:function(Errormap, errorlist) { + varmsg = ""; -$.each (Errorlist,function(i,v) { +msg + = (v.message+ "\ r \ n"); A }); at if(msg!= "") -Ext.Msg.alert (' form ', MSG +fix); - }, -Invalidhandler:function(){ - return false; - }, inSubmithandler:function(){ - //Processing of Forms toExt.Msg.confirm ("Confirm", "confirm send?" + fix,function(button,text) { + if(Button = = ' Yes '){ - loadmarsk.show (); the $.ajax ({ *URL: ' <%=basepath%>promotionaction.do?method=group ', $DataType: ' JSON ',Panax NotoginsengType: ' Post ', -data:$ (' #query '). Serialize (), theErrorfunction(){ +Ext.Msg.alert (' Error ', ' request error! ' +fix); A loadmarsk.hide (); the }, +Successfunction(data) { -Ext.Msg.alert (' success ', Data.msg +fix); $ loadmarsk.hide (); $ } - }) - } the} );//Confirm - return false;//block form submissionWuyi } the});
The key is: Validate's Submithandler,invalidhandler These 2 methods all need to overwrite, all return false;
Transferred from: http://www.cnblogs.com/longterm/archive/2012/05/18/2507594.html
"Reprint" jquery Validate validation plugin, validation in AJAX submission mode