Commit ee02ea7e authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

Issue #1765422 by kalabro: Fixed Date widget format ignored in clientside validation.

parent 1d9bca2d
......@@ -1147,22 +1147,35 @@
jQuery.validator.addMethod("dateFormat", function(value, element, param) {
var parts = value.split(param.splitter);
var expectedpartscount = 0;
var day = parseInt(parts[param.daypos], 10);
var month = parseInt(parts[param.monthpos], 10);
month = month - 1;
var year = parseInt(parts[param.yearpos], 10);
var date = new Date();
var result = true;
date.setFullYear(year);
if (year !== date.getFullYear()) {
result = false;
if (param.yearpos !== false){
expectedpartscount++;
date.setFullYear(year);
if (year !== date.getFullYear()) {
result = false;
}
}
date.setMonth(month);
if (month !== date.getMonth()) {
result = false;
if (param.monthpos !== false) {
expectedpartscount++;
date.setMonth(month);
if (month !== date.getMonth()) {
result = false;
}
}
if (param.daypos !== false) {
expectedpartscount++
date.setDate(day);
if (day !== date.getDate()) {
result = false;
}
}
date.setDate(day);
if (day !== date.getDate()) {
if (expectedpartscount !== parts.length) {
result = false;
}
return this.optional(element) || result;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment