Customize ErrorList Message
I need a way to append the LABEL that is associated with the INPUT that is captured in the errorList; in other words I need to have a summary of errors and I need to know which field created the error. Also, I am using the smart wizard to assist in navigating the form.
My code:
showErrors: function (errorMap, errorList) {
$.each(errorList, function (name, value) {
var $errorLabel = $('label[for="' + $(this.element).attr('id') + '"]').text();
this.message = this.message.replace("#{field}", $errorLabel);// $errorLabel + " " + this.message;
});
this.defaultShowErrors();
}
When I click the "Next" button, my form is validated and returns the correct error message:
"Last Name is required"
But if I go back to that wizard step and it validates it again, the new error message is:
"Last NameLast Name is required is required"
And if I validate again is keeps appending! I am not sure why it is growing my message. I may be modifying the error message in the wrong location but I do not know where else to manipulate it from.
I am trying to avoid having to create a messages: {} on the validator listing all my required fields but I can't use the default "This field is required" message either.
Please help! TIA!!