Home Web Front-end JS Tutorial Some exception analysis of ajaxValidator of formValidator3.3_jquery

Some exception analysis of ajaxValidator of formValidator3.3_jquery

May 16, 2016 pm 06:04 PM

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.
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Replace String Characters in JavaScript

Custom Google Search API Setup Tutorial Custom Google Search API Setup Tutorial Mar 04, 2025 am 01:06 AM

Custom Google Search API Setup Tutorial

Example Colors JSON File Example Colors JSON File Mar 03, 2025 am 12:35 AM

Example Colors JSON File

10 jQuery Syntax Highlighters 10 jQuery Syntax Highlighters Mar 02, 2025 am 12:32 AM

10 jQuery Syntax Highlighters

8 Stunning jQuery Page Layout Plugins 8 Stunning jQuery Page Layout Plugins Mar 06, 2025 am 12:48 AM

8 Stunning jQuery Page Layout Plugins

Build Your Own AJAX Web Applications Build Your Own AJAX Web Applications Mar 09, 2025 am 12:11 AM

Build Your Own AJAX Web Applications

What is 'this' in JavaScript? What is 'this' in JavaScript? Mar 04, 2025 am 01:15 AM

What is 'this' in JavaScript?

10  JavaScript & jQuery MVC Tutorials 10 JavaScript & jQuery MVC Tutorials Mar 02, 2025 am 01:16 AM

10 JavaScript & jQuery MVC Tutorials

See all articles