Side navigation
#3866 closed enhancement (invalid)
Opened January 15, 2009 10:48AM UTC
Closed February 05, 2010 08:35PM UTC
[validate] dateDE validation with sanity checks
Reported by: | Peter Grefenstein | Owned by: | joern |
---|---|---|---|
Priority: | minor | Milestone: | 1.3 |
Component: | plugin | Version: | 1.2.6 |
Keywords: | validate dateDE | Cc: | |
Blocked by: | Blocking: |
Description
I suggest to extend the dateDE method with sanity check.
dateDE: function(value, element) {
if (/^\\d\\d?\\.\\d\\d?\\.\\d\\d(\\d\\d)?$/.test(value)) {
var dateElements = value.split(".");
if(dateElements[2].length == 2 )
dateElements[2] = 20 + dateElements[2];
var newDate = new Date(dateElements[2], dateElements[1]-1, dateElements[0]);
if ( !/Invalid|NaN/.test(newDate) && (newDate.getDate() == dateElements[0]) && (newDate.getMonth() == dateElements[1]-1) && (newDate.getFullYear() == dateElements[2]))
{
return this.optional(element) || true;
}
}
return false;
},