I already tried searching countless times for this question but none of the answers seem to resolve the issue I am having.
$('.datepicker').datepicker(
{
format: "mm/dd/yyyy",
"setDate": new Date(),
todayHighlight: true,
"autoclose": true,
yearRange: "1990:2100"
});
Basically, I have a datepicker, and I want to prevent the user from typing invalid years (eg: 000, 201, 231) so i want to prevent 3 number years basically. I tried putting yearRange but that doesnt work.
If you're using the jQuery UI Datepicker , you can specify minDate
as -100Y
and that'll constrain the year to within the last 100 years, which would eliminate 3-digit years in 2018.
For the bootstrap datepicker , it looks like you'd use startDate
and again, set it to something like -100Y
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.