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