|
2 | 2 | * jQuery Form Validation |
3 | 3 | * |
4 | 4 | * @author Tom Bertrand |
5 | | - * @version 1.3.2 (2014-08-1) |
| 5 | + * @version 1.3.3 (2014-08-16) |
6 | 6 | * |
7 | 7 | * @copyright |
8 | 8 | * Copyright (C) 2014 Tom Bertrand. |
|
19 | 19 | window.Validation = { |
20 | 20 | form: [], |
21 | 21 | messages: null, |
| 22 | + labels: null, |
22 | 23 | hasScrolled: false |
23 | 24 | }; |
24 | 25 |
|
|
61 | 62 | OPTIONAL: /^.*$/, |
62 | 63 | // Validate values or length by comparison |
63 | 64 | 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') |
67 | 65 | }; |
68 | 66 |
|
69 | 67 | /** |
|
101 | 99 | validationMessage: 'data-validation-message', |
102 | 100 | regex: 'data-validation-regex', |
103 | 101 | regexMessage: 'data-validation-regex-message', |
104 | | - validationGroup: 'data-validation-group', |
| 102 | + group: 'data-validation-group', |
| 103 | + label: 'data-validation-label', |
105 | 104 | errorList: 'data-error-list' |
106 | 105 | }; |
107 | 106 |
|
|
147 | 146 | } |
148 | 147 | }, |
149 | 148 | messages: {}, |
| 149 | + labels: {}, |
150 | 150 | debug: false |
151 | 151 | }; |
152 | 152 |
|
|
234 | 234 |
|
235 | 235 | for (var method in options) { |
236 | 236 |
|
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]; |
238 | 243 | continue; |
239 | 244 | } |
240 | 245 |
|
|
507 | 512 | var value = _getInputValue(input), |
508 | 513 |
|
509 | 514 | 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], |
511 | 519 |
|
512 | 520 | validationArray = $(input).attr(_data.validation), |
513 | 521 | validationMessage = $(input).attr(_data.validationMessage), |
|
798 | 806 | return false; |
799 | 807 | } |
800 | 808 |
|
801 | | - group = input.attr(_data.validationGroup); |
| 809 | + group = input.attr(_data.group); |
802 | 810 |
|
803 | 811 | if (group) { |
804 | 812 |
|
|
810 | 818 | errorContainer = label; |
811 | 819 | } |
812 | 820 |
|
813 | | - //$(node).find('[' + _data.validationGroup + '="' + group + '"]').addClass(options.submit.settings.errorClass) |
| 821 | + //$(node).find('[' + _data.group + '="' + group + '"]').addClass(options.submit.settings.errorClass) |
814 | 822 |
|
815 | 823 | } else { |
816 | 824 |
|
|
0 commit comments