jquery validation problems
Posted
by CoffeeCode
on Stack Overflow
See other posts from Stack Overflow
or by CoffeeCode
Published on 2010-03-26T09:37:51Z
Indexed on
2010/03/26
10:53 UTC
Read the original article
Hit count: 292
to custom validate an input i wrote a script:
function cardNumberCheck(value, element) {
var res = false;
$.get("/CaseHistories/ValidateCardNumber",
{ caseHistoryId: $('#CaseHistory_Id').val(), cardNumber: $('#CaseHistory_CardNumber').val() },
function(data) { res = data });
//alert(res) => works fine return true/false
return res;
}
$.validator.addMethod("cardValidate",
cardNumberCheck, "invalid");
if ($('#CaseHistory_CardNumber').is("form *")) { //<= check if elem is in a form
$('#CaseHistory_CardNumber').rules("add", {
required: true,
cardValidate: true,
messages: {
required: "*",
cardValidate: "invalid"
}
});
}
EDIT:
the required rule works fine, but my validation method doesn't dispalt the message.
and the submit works even if the elements data havent passed the cardNumberCheck validation
whats not right here?
© Stack Overflow or respective owner