This method sets the allowed days of the week, that can be entered into the Date control. To restrict the manual user input, create a custom validation plugin for the Edit as: Date fields.
Alternatively, you can set up the allowed weekdays and the validation with the Edit as: Date options.
Note: the "allowed" status and the message for each day are stored separately, so you can use this method several times to define individual messages for each set of days.
Syntax
ctrl.toggleWeekDay( day, enable: boolean, message: string )
Arguments
day
a number or an array of numbers, where 0 - is a Sunday, 1 - is a Monday, etc.;
enable
a boolean variable, enables or disables the allowed days of the week;
message
an error message that is displayed when a date outside of the selected interval is selected. If no message is specified, a default one is displayed.
Return value
No return value.
Example
toggleWeekDay() can be used in the JavaScript OnLoad event, as well as any other JavaScript event.
Restrict selecting Friday and Sunday/Monday/Tuesday with 2 different messages:
var ctrl = Runner.getControl(pageid, 'datefield');
//restrict selecting Friday, show error message 1 when selected
ctrl.toggleWeekDay( 5, false, 'error message 1' );
//restrict selecting Sunday, Monday, Tuesday, show error message 2 when selected
ctrl.toggleWeekDay( [0,1,2], false, 'error message 2');
Note: replace "datefield" and each of the "error message" with the actual field name and error message in the function.
See also:
•JavaScript API: Control object > getControl()
•"Edit as" settings: Validation types