You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since datejs and others make tweaks to the Date.parse, and it's
specifically easier to override in terms of prototypal enhancement in
JS, I'd suggest updating the date validation to the following...
I am also annoyed by the default date validator, since it does only basic syntax checking, (e.g. a german date like "99.99.2011" validates). But do we really need to depend on date.js for enhanced checking?
Since an "invalid" date object like (new Date (2008,99,99)) is converted to a future/past date (in this case to 8th march 2016), you can use the following algorithm:
create new Date object enteredDate from the entered year, month, day values
check if enteredDate.getFullYear() == enteredYear && !!enteredDate.getFullYear() (prevent falsy values,)
check if enteredDate.getMonth() == enteredMonth-- && !!enteredDate.getMonth()
same goes for Day (Date)
this could happen in a simple external function that is invoked by all culture-specific date validators once they extracted
the year, month, day values from the entered date.
Since datejs and others make tweaks to the Date.parse, and it's
specifically easier to override in terms of prototypal enhancement in
JS, I'd suggest updating the date validation to the following...
This should support situations where Date and/or Date.parse are enhanced
to handle additional parsing. :)
The text was updated successfully, but these errors were encountered: