Ajaxvalidator Common problem Solving (ginseng, Chinese garbled)

Source: Internet
Author: User

Ajaxvalidator Common problem Solving (ginseng, Chinese garbled)

The following is the author's statement to Ajaxvalidator:
Ajaxvalidator is one of the most asked questions, fix a bug (thank netizens "じ?? W√ "), and to the most concerned about the issue, and then make an elaboration.
Bug phenomenon: No matter check has no check pass, when the control again get focus and lose focus again when the tip of tip will stagnate in the focus of the hint
Related records of previous upgrades:
A, add a Addidvalue property to the Ajaxvalidator (automatically add IDs and values to the URL parameter)
In order to repair ajaxvalidator in the configuration information, the Run-time value of the bug, the plug-in will automatically be automatically added after the URL, in the form of "Id=value" page parameters.
On the server side, you can take the value by request.querystring["id". For a specific demo, look at the user name input and default.asp tutorials in Demo1 x
Exception Description:
Garbled problems will still occur during the development process
For example:
$ ("#thename"). Formvalidator ({onfocus: "User name is at least 6 characters, up to 40 characters", Oncorrect: "Input format is correct"}). Inputvalidator ({min:6,max:40, OnError: "The username you entered is illegal, please confirm"}//.regexvalidator ({regexp: "username", datatype: "Enum", OnError: "Incorrect username format"})
. Ajaxvalidator ({
Type: "Get",
URL: "Login.do",
Data: "Action=isexist",
DataType: "XML",
Success:function (data) {
root = data.documentelement;
var rowSet = root.selectnodes ("//delete");
if (Rowset.item (0). selectSingleNode ("value"). Text = = "0")
{
return true;
}
Else
{
return false;
}
},
Buttons: $ ("#saveId"),
Error:function () {alert ("The server does not return data, the server may be busy, please try again");
OnError: "This username is not available, please change user name",
Onwait: "The user name is being validated for legality, please wait ..."//function () {Alert ($ ("#pcode"). Val ());
});
Description
Data: "Action=isexist&thename=" +$ (' #thename '). Val (), which is invalidated because $ (' #thename '). Val () is fixed, and is an initial value, usually empty.
Modify the source code:
Formvalidator.js
Ajax Checksum
In the Ajaxvalid:function (Returnobj) method
Will
var parm = "clientid=" +id+ "&" +id+ "=" +encodeuricomponent (Srcjo.val ());
To
var parm = "clientid=" +id+ "&" +id+ "=" +encodeuricomponent (encodeURIComponent (Srcjo.val ()));
Because only through the front two times coding, background decoding can solve the garbled problem
Thename=java.net.urldecoder.decode (thename, "UTF-8");


For URLs in Ajaxvalidator in jquery formvalidator ver3.3 cannot pass dynamic values

Some anomalies in the ajaxvalidator of formValidator3.3 (1)

The following is the author's statement to Ajaxvalidator:

Ajaxvalidator is one of the most asked questions, fix a bug (thank netizens "じ?? W√ "), and to the most concerned about the issue, and then make an elaboration.
Bug phenomenon: No matter check has no check pass, when the control again get focus and lose focus again when the tip of tip will stagnate in the focus of the hint
Related records of previous upgrades:
A, add a Addidvalue property to the Ajaxvalidator (automatically add IDs and values to the URL parameter)
In order to repair ajaxvalidator in the configuration information, the Run-time value of the bug, the plug-in will automatically be automatically added after the URL, in the form of "Id=value" page parameters.
On the server side, you can take the value by request.querystring["id". For a specific demo, look at the user name input and default.aspx in Demo1.

Treatment mode:

Ajax Checksum
In the Ajaxvalid:function (Returnobj) method

Will

var parm = "clientid=" +id+ "&" +id+ "=" +encodeuricomponent (Srcjo.val ());

To

var parm = "clientid=" +id+ "&" +id+ "=" +encodeuricomponent (encodeURIComponent (Srcjo.val ()));

Because only through the front two times coding, background decoding can solve the garbled problem

Thename=java.net.urldecoder.decode (thename, "UTF-8");

Note that the front desk must be encoded two times, otherwise it will still be garbled.

============================================

The above scenario only resolves the ID of the passed control, and still cannot pass the other values.

For example: if the following requirements need to be in the designated area in the selected service time, you must dynamically transfer province, city, county information

Using the original scheme, the code is as follows:

$ ("#pbookingtime"). focus (function () {Wdatepicker ({skin: ' Whygreen ', datefmt: ' Yyyy-mm-dd HH:mm:ss ', mindate: '%y-%m-% d ', maxdate: '%y-%m-/# ', Oncleared:function () {$ (this). blur ();},onpicked:function () {$ (this). blur ();}})}). Formvalidator ({onshow: "Please enter the appointment time", onfocus: "Please enter the appointment time", Oncorrect: "√"}). Inputvalidator ({min: "2008-01-01 00:00:00", Max: "2010-01-01 23:59:59", type: "datetime", OnError: "Date must be between/" 1900-01-01/"and/" 3000-01-01/"}//;//.defaultpassed () ;
. Ajaxvalidator ({
Type: "Get",
URL: "<%=path%>/archives/sertime.do",
Data: "action=sertimeverify&ram=" + math.random () + "&search.pprovince=" +$ ("#pprovince"). Val () + & Search.pcity= "+$ (" #pcity "). Val () +" &search.pcounty= "+$ (" #pcounty "). Val (),
DataType: "XML",
Success:function (data) {
root = data.documentelement;
var rowSet = root.selectnodes ("//result");
if (Rowset.item (0). selectSingleNode ("value"). Text = = "0")
{
return false;
}
Else
{
return true;
}
},
Buttons: $ ("#btnupdate"),
Error:function () {alert ("The server does not return data, the server may be busy, please try again");
OnError: "The appointment time is not within the service time range!",
Onwait: "The validity of the appointment time is verified, please wait ..."
});

/* for Ajaxvalidator dynamic transfer value can not be successful, reference ajaxvalidator the original code in the following ways to implement * *

$ ("#pbookingtime"). focus (function () {Wdatepicker ({skin: ' Whygreen ', datefmt: ' Yyyy-mm-dd HH:mm:ss ', mindate: '%y-%m-% d ', maxdate: '%y-%m-/# ', Oncleared:function () {$ (this). blur ();},onpicked:function () {$ (this). blur ();}})}). Formvalidator ({onshow: "Please enter the appointment time", onfocus: "Please enter the appointment time", Oncorrect: "√"}). Inputvalidator ({min: "2008-01-01 00:00:00", Max: "2010-01-01 23:59:59", type: "datetime", OnError: "Date must be between/" 1900-01-01/"and/" 3000-01-01/"}//;//.defaultpassed () ;

. Functionvalidator ({
Fun:function (Val,elem) {
$.ajax (
{
Mode: "Abort",
Type: "Get",
URL: "<%=path%>/archives/sertime.do",
Data: "Action=sertimeverify&search.pbookingtime=" + $ ("#pbookingtime"). Val () + "&search.pprovince=" +$ ("# Pprovince "). Val () +" &search.pcity= "+$ (" #pcity "). Val () +" &search.pcounty= "+$ (" #pcounty "). Val (),
DataType: "xml",
Success:function (data) {
root = data.documentelement;
var rowSet = root.selectnodes ("//result");
if (Rowset.item (0). selectSingleNode ("value"). Text = = "0")
{
$.formvalidator.settipstate (Elem, "OnError", "booking time is not within the scope of service time!");
return false;
}
Else
{
$.formvalidator.settipstate (Elem, "OnError", "√");
return true;
}
},
Complete:function () {
$ ("#btnupdate"). attr ({"Disabled": false});
$ ("#btnupdateauding"). attr ({"Disabled": false});
},
Beforesend:function (XHR) {
Callback the Submit button before the server returns data
$ ("#btnupdate"). attr ({"Disabled": true});
$ ("#btnupdateauding"). attr ({"Disabled": true});
$.formvalidator.settipstate (Elem, "OnLoad", "the validity of the appointment time is verified, please wait ...");
},
Error:function () {
$.formvalidator.settipstate (Elem, "OnError", "Server does not return data, possible server busy, please try again");
Alert ("The server does not return data, the server may be busy, please try again");
}
});
}
});

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.