I've been playing with Jörn's excellent validation plugin (beta 2) to try
and get it to validate individual fields using ajax on blur. It's a pretty
basic attempt (because I'm sure Jörn is going to do something much better
soon :), but I've got stuck and I can't fathom out why. I've added a new
method called remote that I call in my rules like this:
headerx: {remote: "/gen/valid.cfm"}
And in the validate.js the new method looks like this:
remote: function(value, element, remoteurl) {
$.getJSON(remoteurl+"?value="+value,
function(data){
//alert(data.SUCCESS);
if(data.SUCCESS == 'true'){
return true;
}
});
},
It works to point; the validation page is called and the value is passed
correctly, the validation page does its stuff and passes back true or false
depending on the result being good or bad and the alert displays the correct
true/false result. But, I can't seem to get the 'if' statement to work and,
even if I put 'return true' above the 'if' (but below the $.getJSON) it
always returns false.
This is the first time I've used jQuery so A) I'm pretty pleased I got this
far and B) if what I'm doing looks stupid, please forgive me :)
If anyone can offer a clue I'd appreciate it.
Thanks
Gareth
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/