How to Restrict the Calendar Picker to Weekdays Only
The popup calendar can be restricted to show only weekdays using a little custom javascript, executed when the form loads. We can create an action on the forms root node (these actions will run when the form loads), and call it to modify one of the properties of the pop up calendar.
Here are the steps:
- Click on the name of your form in the outline panel in the Form Designer
- Find and click on actions in the General Settings Property Panel
- Create a new Action and choose Custom JavaScript
- Give the action a name, and click next.
- Enter the following code, but replace "End Date" with the name of your field (the name must match exactly and IS case sensitive)
// This function will receive the field and form objects. function(field,form){ var datepicker = form.getFieldByName('End Date').getDatePicker(); datepicker.settings.beforeShowDay = $.datepicker.noWeekends }
Save your changes and test your form. When you open the calendar, weekends should now be grayed out.
Have more questions? Submit a request
-
Clinton Tu You can also use the following code to restrict to Mondays only (from https://stackoverflow.com/questions/3805486/jquery-datepicker-only-select-mondays-and-thursdays)
function(field,form){
var datepicker = form.getFieldByName('End Date').getDatePicker();
datepicker.settings.beforeShowDay = function(date){
var day = date.getDay();
return [day == 1 || day == 4,""];
}
}
Please sign in to leave a comment.
1 Comments