[jQuery] validate classbased via ajax request
Hello,
my forms are all css class based validated. Now I need to check some on them serverside, so I overload the regular validation methods (or is there a better way?).
jQuery.validator.addMethod("date", function(value, element) {
var preValid = this.optional(element) || /^\d\d?\/\d\d?\/\d\d\d?\d?$/.test(value);
if (!preValid)
return false;
$.getJSON(urlDefs.validateDate + "?date=" + value, function(data) {
var result = data.Data;
// what can I do with this result?
// how can I set element valid?
});
}, jQuery.validator.messages['date']);
<br clear="all">
I might be doing something wrong...
I know there is a remote({}) method, but how could I use it from there? It might work less asynchronously, thus easier...
--
Jan