Formvalidator Verification Plugin for AJAX validation issues _jquery

Source: Internet
Author: User
Tags tomcat
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
Related Article

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.