Allow flexibility with date input
Posted on 2014-04-13
I have a website with a grid that allows users to input dates. For one of the columns, the grid brings up a calendar control that users can pick. The calendar control and column requires that the date be entered in the format dd/mm/yyyy. The column also allows manual input, but requires that the full 4 digit year be entered.
The grid allows short months and day (ie no leading zero), but requires that the full four digit year be entered. I can validate entry into the grid, but need some code to check to see if the year has been entered, and if not, supplement the entry with the current year.
Entering 4/1/2014 works.
Entering 4/1/14 does NOT work.
Entering 4/1 does NOT work.
So, if the user only enters a two digit year, I want the code to add "20" to the front.
If the user does not enter a year, I want the code to append the current year.
I would love to add this flexibility to my website. Thank you in advance. Brian