how do i disable the past dates in a datepicker (calendar) in Jquery ui? -
i developing booking system , need disable past dates using jquery. have downloaded jqueryui , trying use beforeshowday function disable past dates.
if you're using de datepicker can restrict date range follows:
$( "#datepicker" ).datepicker({ mindate: -20, maxdate: "+1m +10d" });
the -20 means 20 days before, maxdate 1 month , 10 days current day.
to avoid user select date before current 1 use:
$("#datepicker").datepicker({ mindate: 0 });
source:
https://jqueryui.com/datepicker/#min-max
https://api.jqueryui.com/datepicker/#entry-examples
sample
$( "#datepicker" ).datepicker({ mindate: 0 }); <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>datepicker demo</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> </head> <body> <div id="datepicker"></div> </body> </html>
Comments
Post a Comment