Reputation: 879
Using the JQuery Validation plugin, I have composed the following, but find that the default validation message is displayed rather than my custom message (I have used the constant in other validations, so know that works!). What am i missing?
$("#pageform").validate();
$("input[id^=displayName]").each(function() {
$(this).rules("add", {
maxlength: AGHOSTMOBILEADMIN_VALIDATION.constants.displayNameMaxLength,
messages: {
maxLength: AGHOSTMOBILEADMIN_VALIDATION.format.displayName
}
});
});
$("input[id^=navigationLabel]").each(function() {
$(this).rules("add", {
maxlength: AGHOSTMOBILEADMIN_VALIDATION.constants.navigationLabelMaxLength,
messages: {
maxLength: AGHOSTMOBILEADMIN_VALIDATION.format.navigationLabel
}
});
});
Upvotes: 0
Views: 407
Reputation: 5655
try this..
messages: {
maxLength: AGHOSTMOBILEADMIN_VALIDATION.format.navigationLabel
}
to
messages: {
maxlength: AGHOSTMOBILEADMIN_VALIDATION.format.navigationLabel
}
Note MaxLenth changed to maxlength (L become l)
So complete code should look like
$("#pageform").validate();
$("input[id^=displayName]").each(function() {
$(this).rules("add", {
maxlength: AGHOSTMOBILEADMIN_VALIDATION.constants.displayNameMaxLength,
messages: {
maxlength: AGHOSTMOBILEADMIN_VALIDATION.format.displayName
}
});
});
$("input[id^=navigationLabel]").each(function() {
$(this).rules("add", {
maxlength: AGHOSTMOBILEADMIN_VALIDATION.constants.navigationLabelMaxLength,
messages: {
maxlength: AGHOSTMOBILEADMIN_VALIDATION.format.navigationLabel
}
});
});
Here is working code
Upvotes: 1