Home > Web Front-end > JS Tutorial > body text

Some exception analysis of ajaxValidator of formValidator3.3_jquery

WBOY
Release: 2016-05-16 18:04:47
Original
1152 people have browsed it

Ajaxvalidator is the most frequently asked question. We have fixed a bug (thank you netizen "じ龙峸√") and elaborated on the issues that everyone is most concerned about.
Bug phenomenon: No matter whether the verification is passed or not, when the control gains focus again and loses focus again, the prompt in the tip will stop at the focus prompt
Related records of previous upgrades:
a. Add an addidvalue attribute to AjaxValidator (whether to automatically add the id and value after the url parameter)
In order to fix the bug that AjaxValidator cannot get the runtime value when configuring information, the plug-in will automatically add it after the url. Web page parameters in the form of "id=value".
On the server side, you can get the value through Request.querystring["id"]. For specific demonstrations, please see the username input and Default.aspx in demo1
Exception description:
Garbled characters will still occur during the development process
For example:

Copy code The code is as follows:

$("#thename").formValidator({onfocus:"The username must be at least 6 characters and at most 40 characters" ,oncorrect:"The input format is correct"}).inputValidator({min:6,max:40,onerror:"The user name you entered is illegal, please confirm"})//.regexValidator({regexp:"username",datatype :"enum",onerror:"The username format is incorrect"})
.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 did not return data. The server may be busy, please try again" );},
onerror: "The username is not available, please change the username",
onwait: "The username is being verified for validity, please wait..."//function() {alert($("#pcode").val());}
});

Description:
data:"action=isExist&thename=" $('#thename ').val(), this method is invalid because $('#thename').val() is fixed and is the initial value, usually empty.
Modify the source code:
formValidator.js
//ajax verification
ajaxValid: In the method of function(returnObj),
will
var parm = "clientid=" id "&" id "=" encodeURIComponent(srcjo.val ());
Changed to:
var parm = "clientid=" id "&" id "=" encodeURIComponent(encodeURIComponent(srcjo.val()));
Because it is only encoded twice through the frontend , one decoding in the background can solve the garbled code problem
thename=java.net.URLDecoder.decode(thename, "UTF-8");
Note that the frontend must encode twice, otherwise it will still be garbled.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!