In web development, taking date input from user is commonly occurs. The jQuery Date picker provides excellent user interface and user experience. It also provide many functionality like start date, end date, format date for user display or more.
While taking date input sometimes we need to skip some dates or need to force user to select date except some date days or dates like weekends or holidays. Without datepicker we need to validate it against user input but date picker provides functionality to disable some dates while taking user input easily.
For example, we are creating HRMS or school application which has leave module. So it normal to take leave on working days only. User can not apply leave on weekends. In this example, we will disable weekends from datepicker instance using jQuery.
In above code, we have used libraries like bootstrap, jquery-ui and jquery and defined single input with id as datepicker. Then in document ready method, we have initialized jQuery datepicker. While initializing jQuery Datepicker, we have applied beforeShowDay property and it's value for disable weekends.
While someone tries to select date then it will show weekends disabled and user can not select Saturday or Sunday. Below is simple output image for above example.
In this article, we have created simple date input and disabled weekends for that input. There are many options or properties which can be useful with datepicker.
Ask anything about this examples