Side navigation
#3486 closed bug (worksforme)
Opened October 15, 2008 05:50PM UTC
Closed June 10, 2009 10:53AM UTC
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>");
}
Attachments (0)
Change History (3)
Changed October 16, 2008 08:57PM UTC by comment:1
cc: | → jbowles |
---|---|
component: | unfilled → plugin |
keywords: | → validate |
owner: | flesler → joern |
Changed November 25, 2008 07:18PM UTC by comment:2
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.
Changed June 10, 2009 10:53AM UTC by comment:3
resolution: | → worksforme |
---|---|
status: | new → closed |
Set ignoreTitle option.