validator.addMethod question
Hi,
I have a question regarding the validator.addMethod. Specifically my question deals with the message part of the addMethod function. I have the following code in my document.ready function.
$(document).ready(function() {
var message = "";
jQuery.validator.addMethod("IsSelectionValid", function(value, element, param) {
var result = true;
if ($('#auditTypeDropDownList option:selected').val() == '1' && element.id == 'opinionDropDownList') {
if (value == '7' || value == '8') {//7 = other 8 = N/A
result = false;
message = "<br />* Can use all choices except Other and N/A";
}
else {
result = true;
}
}
else if ($('#auditTypeDropDownList option:selected').val() == '2' && element.id == 'opinionDropDownList' ||
$('#auditTypeDropDownList option:selected').val() == '3' && element.id == 'opinionDropDownList') {
if (value == '8') {
result = true;
}
else {
result = false;
message = "<br />* N/A is the only available option for audit opinion with this audit type";
}
}
return result;
},message);
});
The problem is I'm unable to get the message to be displayed. When I put the message variable in an alert I can see the text just fine. Could someone help me to figure out where I'm going wrong? Please note I've omitted unnecessary code for easier understanding.
Regards,
Garfield