jQuery Validate, How to give custom error from the custom function based on the different condition???.
Here is the sample code. This is not my actual code. Here I'm trying to put my problem in the sample code.
I've modified the default required functionality with custom function. But how can i give the proper message based on the different conditions.
rules: {
"data[Model][field1]": {
required:function(){
var myValue = $('#myfield').val();
if( myValue < '5') {
// Here i want to assign different error message
return false;
} else if( myValue > '10') {
// Here i want to assign different error message
return false;
} else {
return true;
}
}
},
messages: {
"data[Model][field1]":{ "required":"How can i get the above messages here??" }
}