The ajaxvalidator difference between the Ajax judgment repetition and formvalidator of ordinary jquery

Source: Internet
Author: User
Tags repetition

Example: Version 1.ajax:

$ ("#txtTitle"). blur (function () {
$.ajax ({
Type: "GET",
URL: "Handler.ashx?" Newsadd=1&txtname= "+ encodeURIComponent ($ (this). Val ()) +" ",
Data:null,
Success:function (msg) {
if (msg! = "") {
Flag = false;
Alert ("Do not repeat add!");
}
Else
Flag = true;
},
Onerror:function () {alert ("Error")}
});
});

Version 2.ajaxValidator

$ ("#txtName"). Formvalidator ({onshow: "Please fill in the Item name", onfocus: "Item name must be entered"}). Inputvalidator ({min:1, max:50, empty: {leftemp Ty:false, Rightempty:false, Emptyerror: "Cannot have Space"}, OnError: "Item name input error, may exceed the length"}). Ajaxvalidator ({
Url:oldvalue = = ""? " Handler.ashx? Goodsadd=1 ":" Handler.ashx? Goodsedit=1&oldvalue= "+ OldValue +" ",
Addidvalue:true,
Success:function (data) {
if (data = = "1")
return false;
Else
return true;
},
Buttons: $ ("#lbSubmit"),
Error:function () {alert ("error");},
OnError: "Please do not add again",
Onwait: "Verifying duplicates, please wait ..."
}). defaultpassed ();//Modify the time to add

Places to be aware of:

The 1.ajaxValidator passes through $ (ID) to get the null value forever. So, with the addidvalue:true solution. Automatically chase Controlid=idvlaue on the URL;

2.$.ajax in onerror represents the server program error state, while Ajaxvalidator represents, success state, return false case. The error in Ajaxvalidator represents the server.

3.ajaxValidator Modify the time, verify the repetition time to add defaultpassed (), otherwise it has been verified wrong

The ajaxvalidator difference between the Ajax judgment repetition and formvalidator of ordinary jquery

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.