Ajax verification issues in the formvalidator verification plug-in

Source: Internet
Author: User

Jquery formvalidator plug-in is a good domestic validation plug-in, it is very convenient to do some common verification, but recently encountered a problem that if the form is submitted by AJAX, you cannot follow the traditional practice, for example: Copy codeThe Code is as follows: $ ajax. post ("...............")
$. FormValidator. initConfig ({formID: "applyForm", onError: function (msg) {alert (msg )}});
$ ("# Reason"). formValidator (). inputValidator ({min: 1, onErrorMin: 'Enter the application content and reason '});

Unfortunately, the result of submitting an ajax form and using formvalidator for verification is not met. If you want to use both formvalidator and ajax for submission, you will first see the usage of ajaxform in the formvalidtor manual.Copy codeThe Code is 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: 'The data is being asynchronously verified. Please wait ...'
});

After reading this, this method seems acceptable, but in fact, it is not very helpful to Chinese.
Struts2, spring 3, tomcat is also using UTF-8, sturts2 and so on all encoded with a UTF-8, but it is still said that when take
When speaking of struts2's Chinese value:
Org. apache. tomcat. util. http. Parameters processParameters
Warning: Parameters: Character decoding failed. Parameter skipped.
Java. io. CharConversionException: isHexDigit.
For the solution, see:
Http://www.iteye.com/problems/7099
However, this problem is very strange, and it is too troublesome to use formvalidtor, so I found another method, which is really easy to use.Copy codeThe Code is as follows: if ($. formValidator. pageIsValid ('1') = true)
{
$. Post ("xxxxxxxxxxxxxxxxx ")
}

Other validation rules are still written. If there is only one form on the page, the default value is 1. The pageIsValid here is used to verify that all the controls in this group have passed the verification and 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.