Reputation: 4028
I have a SharePoint Date Picker Control which is used to select a BirthDate . I want the birthdate to be atleast 16years older from the current date.
Can anyone guide me how to validate this using javascript? I have not used javascript much, Please guide me how to go about the validation process?
Upvotes: 0
Views: 364
Reputation: 6572
Look at using the library date.js:-
This library adds a number of methods for working with date objects.
Without using an external library, the easiest way to compare a date of birth is over 16 is to convert the date to an epoch timestamp and then compare this against a timestamp of now minus 16 years.
Be aware that while most languages/platforms use timestamps in seconds, Javascript uses milliseconds, so when comparing against timestamps from external sources, you need to divide by a factor of 1000.
Upvotes: 1