Skip to content

Commit e9c245a

Browse files
author
Matt Clements
committed
Fixed issue with Leap Years being shown as incorrect Dates
29/02/2012 was a Leap Year, but was being shown as an incorrect Date
1 parent e532291 commit e9c245a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

jquery.formvalidator.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ jQueryFormUtils.parseDate = function(val, dateFormat) {
467467
var day = findDateUnit('d', formatParts, matches);
468468
var year = findDateUnit('y', formatParts, matches);
469469

470-
if (month === 2 && day > 28 || month > 12 || month === 0) {
470+
if ((month === 2 && day > 28 && (year % 4 !== 0 || year % 100 === 0 && year % 400 !== 0))
471+
|| (month === 2 && day > 29 && (year % 4 === 0 || year % 100 !== 0 && year % 400 === 0))
472+
|| month > 12 || month === 0) {
471473
return false;
472474
}
473475
if ((this.isShortMonth(month) && day > 30) || (!this.isShortMonth(month) && day > 31) || day === 0) {

0 commit comments

Comments
 (0)