|
1958 | 1958 | badTelephone: 'You have not given a correct phone number',
|
1959 | 1959 | badSecurityAnswer: 'You have not given a correct answer to the security question',
|
1960 | 1960 | badDate: 'You have not given a correct date',
|
1961 |
| - badDateBefore: 'The minimum allowed date is ', |
1962 |
| - badDateAfter: 'The maximum allowed date is ', |
1963 | 1961 | lengthBadStart: 'The input value must be between ',
|
1964 | 1962 | lengthBadEnd: ' characters',
|
1965 | 1963 | lengthTooLongStart: 'The input value is longer than ',
|
|
2288 | 2286 |
|
2289 | 2287 | /*
|
2290 | 2288 | * Validate date
|
2291 |
| - * element attrs (optional, and both must use the same format as the field) |
2292 |
| - * data-validation-min-date |
2293 |
| - * data-validation-max-date |
2294 | 2289 | */
|
2295 | 2290 | $.formUtils.addValidator({
|
2296 | 2291 | name: 'date',
|
2297 |
| - validatorFunction: function (date, $el, conf, lang) { |
| 2292 | + validatorFunction: function (date, $el, conf) { |
2298 | 2293 | var dateFormat = $el.valAttr('format') || conf.dateFormat || 'yyyy-mm-dd',
|
2299 | 2294 | addMissingLeadingZeros = $el.valAttr('require-leading-zero') === 'false';
|
2300 |
| - var dateParsed = $.formUtils.parseDate(date, dateFormat, addMissingLeadingZeros); |
2301 |
| - //checking date format |
2302 |
| - if (dateParsed === false){ |
2303 |
| - this.errorMessage = lang.badDate; |
2304 |
| - return false; |
2305 |
| - } |
2306 |
| - var dateInput = new Date(dateParsed[0], dateParsed[1] - 1, dateParsed[2]); |
2307 |
| - //checking min date, when informed |
2308 |
| - var dateMinValue = $el.valAttr('min-date'); |
2309 |
| - if (dateMinValue !== false && $.formUtils.parseDate(dateMinValue, dateFormat, addMissingLeadingZeros) !== false){ |
2310 |
| - var dateMinParsed = $.formUtils.parseDate(dateMinValue, dateFormat, addMissingLeadingZeros); |
2311 |
| - var dateMin = new Date(dateMinParsed[0], dateMinParsed[1] - 1, dateMinParsed[2]); |
2312 |
| - if (dateInput < dateMin){ |
2313 |
| - this.errorMessage = lang.badDateBefore + dateMinValue; |
2314 |
| - return false; |
2315 |
| - } |
2316 |
| - } |
2317 |
| - //checking max date, when informed |
2318 |
| - var dateMaxValue = $el.valAttr('max-date'); |
2319 |
| - if (dateMaxValue !== false && $.formUtils.parseDate(dateMaxValue, dateFormat, addMissingLeadingZeros) !== false){ |
2320 |
| - var dateMaxParsed = $.formUtils.parseDate(dateMaxValue, dateFormat, addMissingLeadingZeros); |
2321 |
| - var dateMax = new Date(dateMaxParsed[0], dateMaxParsed[1] - 1, dateMaxParsed[2]); |
2322 |
| - if (dateInput > dateMax){ |
2323 |
| - this.errorMessage = lang.badDateAfter + dateMaxValue; |
2324 |
| - return false; |
2325 |
| - } |
2326 |
| - } |
2327 |
| - return true; |
2328 |
| - } |
2329 |
| - //errorMessage: '', //setted above on the function |
2330 |
| - //errorMessageKey: 'badDate' //not used |
| 2295 | + return $.formUtils.parseDate(date, dateFormat, addMissingLeadingZeros) !== false; |
| 2296 | + }, |
| 2297 | + errorMessage: '', |
| 2298 | + errorMessageKey: 'badDate' |
2331 | 2299 | });
|
2332 | 2300 |
|
| 2301 | + |
2333 | 2302 | /*
|
2334 | 2303 | * Validate group of checkboxes, validate qty required is checked
|
2335 | 2304 | * written by Steve Wasiura : http://stevewasiura.waztech.com
|
|
0 commit comments