jquery Formvalidator plug-in is a good domestic verification plug-in, do some common checksum is very convenient, but recently encountered a problem, found that if the form of the entire form of Ajax submission, it can not be the traditional approach, such as:
Copy Code code as follows:
$ajax. Post (".... ..... ...")
$.formvalidator.initconfig ({formid: "Applyform", Onerror:function (msg) {alert (msg)}});
$ ("#reason"). Formvalidator (). Inputvalidator ({min:1,onerrormin: ' Please enter the application content and Reason '});
Unfortunately, this alone is not up to the Ajax form submission and with the Formvalidator checksum effect. If you want to use both Formvalidator and Ajax submissions together, the first thing you'll see is the usage of ajaxform in the Formvalidtor manual.
Copy Code code as follows:
$.formvalidator.initconfig ({theme: "Default", Submitonce:true,formid: "Form1", ajaxform:{
DataType: "HTML",
buttons:$ ("#button"),
URL: "Http://www.51gh.net/chkuser.aspx?act=ok"
},
Onerror:function (msg,obj,errorlist) {
$ ("#errorlist"). empty ();
$.map (Errorlist,function (msg) {
$ ("#errorlist"). Append ("[*]" + msg + "
")
});
Alert (msg);
},
Submitafterajaxprompt: ' There's data being validated asynchronously, please wait ... '
});
Look, this method seems to be possible, but in fact, the support of Chinese is not good, I am
Struts2,spring 3,tomcat is also used utf-8,sturts2 and all the UTF-8 encoded, but incredibly still said when taken
Struts2 the Chinese value of the time, said:
Org.apache.tomcat.util.http.Parameters ProcessParameters
Warning: Parameters:character decoding failed. Parameter skipped.
Java.io.CharConversionException:isHexDigit.
see the way to solve:
http://www.iteye.com/problems/7099
But this question is very strange, and the feeling uses the method of Formvalidtor itself too troublesome, so find another method, really good, that is to use
Copy Code code as follows:
if ($.formvalidator.pageisvalid (' 1 ') ==true)
{
$.post ("Xxxxxxxxxxxxxxxxx")
}
Other validation rules are still written, if the page has only one form, the default is 1, here's the Pageisvalid, is the validation of this group of controls all through the check, continue to do something, you see, this is much simpler