Opened 14 years ago
Closed 14 years ago
#3486 closed bug (worksforme)
validator defaultmessage() returning wrong value
Reported by: | jbowles | Owned by: | joern |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | plugin | Version: | 1.2.6 |
Keywords: | validate | Cc: | jbowles |
Blocked by: | Blocking: |
Description
If my element has a title attribute, I can't override a validation message. For example, I want to change "This field is required" to simply "Required". I do that with the following code:
$.extend($.validator.messages, { required: "Required" });
However, the defaultmessage function searches several places in a particular order for the first defined value, and element.title comes before $.validator.messages[] in the list.
See the code excerpt below.
Is there a better way to accomplish my goal short of editing the jquery source myself? I don't want to have to maintain the code change every time a new version of jquery comes out.
code excerpt from jquery.validate.js
defaultMessage: function(element, method) {
return this.findDefined( this.customMessage(element.name, method), this.customMetaMessage(element, method),
the next two lines should be reversed???
element.title undefined, $.validator.messages[method],
"<strong>Warning: No message defined for " + element.name + "</strong>");
}
Change History (3)
comment:1 Changed 14 years ago by
Cc: | jbowles added |
---|---|
Component: | unfilled → plugin |
Keywords: | validate added |
Owner: | changed from flesler to joern |
comment:2 Changed 14 years ago by
comment:3 Changed 14 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Set ignoreTitle option.
I'm currently considering removing the message-from-title code altogether, as it does more harm then good. Need to figure out a way to achieve that without breaking compability.