Skip to content

Commit 09f86ce

Browse files
committed
Version 1.3.3
- Fixed issue where the input name was forced into the message. Documentation: http://www.runningcoder.org/jqueryvalidation/documentation/#validation-labels
1 parent 12873a9 commit 09f86ce

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

html5-form-validation.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"validation",
1010
"input"
1111
],
12-
"version": "1.3.2",
12+
"version": "1.3.3",
1313
"author": {
1414
"name": "Tom Bertrand",
1515
"url": "http://www.runningcoder.org/jqueryvalidation/"

jquery.validation.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* jQuery Form Validation
33
*
44
* @author Tom Bertrand
5-
* @version 1.3.2 (2014-08-1)
5+
* @version 1.3.3 (2014-08-16)
66
*
77
* @copyright
88
* Copyright (C) 2014 Tom Bertrand.
@@ -19,6 +19,7 @@
1919
window.Validation = {
2020
form: [],
2121
messages: null,
22+
labels: null,
2223
hasScrolled: false
2324
};
2425

@@ -61,9 +62,6 @@
6162
OPTIONAL: /^.*$/,
6263
// Validate values or length by comparison
6364
COMPARISON: /^\s*([LV])\s*([<>]=?|==|!=)\s*([^<>=!]+?)\s*$/
64-
// Validate credit card number
65-
//@TODO: Implement this ..
66-
//ZIP: /^(?!([a-y]{1}\d{1}[a-z]{1}[-\s]?\d{1}[a-z]{1}\d{1})$).*$/i.test('g1q b1g')
6765
};
6866

6967
/**
@@ -101,7 +99,8 @@
10199
validationMessage: 'data-validation-message',
102100
regex: 'data-validation-regex',
103101
regexMessage: 'data-validation-regex-message',
104-
validationGroup: 'data-validation-group',
102+
group: 'data-validation-group',
103+
label: 'data-validation-label',
105104
errorList: 'data-error-list'
106105
};
107106

@@ -147,6 +146,7 @@
147146
}
148147
},
149148
messages: {},
149+
labels: {},
150150
debug: false
151151
};
152152

@@ -234,7 +234,12 @@
234234

235235
for (var method in options) {
236236

237-
if (!options.hasOwnProperty(method) || method === "debug") {
237+
if (!options.hasOwnProperty(method) || method === "debug" || method === "messages") {
238+
continue;
239+
}
240+
241+
if (method === "labels" && options[method] instanceof Object) {
242+
tpmOptions[method] = options[method];
238243
continue;
239244
}
240245

@@ -507,7 +512,10 @@
507512
var value = _getInputValue(input),
508513

509514
matches = inputName.replace(/]$/, '').split(/]\[|[[\]]/g),
510-
inputShortName = matches[matches.length - 1],
515+
inputShortName = window.Validation.labels[inputName] ||
516+
options.labels[inputName] ||
517+
$(input).attr(_data.label) ||
518+
matches[matches.length - 1],
511519

512520
validationArray = $(input).attr(_data.validation),
513521
validationMessage = $(input).attr(_data.validationMessage),
@@ -798,7 +806,7 @@
798806
return false;
799807
}
800808

801-
group = input.attr(_data.validationGroup);
809+
group = input.attr(_data.group);
802810

803811
if (group) {
804812

@@ -810,7 +818,7 @@
810818
errorContainer = label;
811819
}
812820

813-
//$(node).find('[' + _data.validationGroup + '="' + group + '"]').addClass(options.submit.settings.errorClass)
821+
//$(node).find('[' + _data.group + '="' + group + '"]').addClass(options.submit.settings.errorClass)
814822

815823
} else {
816824

0 commit comments

Comments
 (0)