Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > JavaScript API > Date Control API > Methods

JavaScript API: Date Control API > toggleWeekDay()

Scroll Prev Next More


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.


ctrl.toggleWeekDay( day, enable: boolean, message: string )



a number or an array of numbers, where 0 - is a Sunday, 1 - is a Monday, etc.;


a boolean variable, enables or disables the allowed days of the week;


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.


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

"Edit as" settings: Date

"Edit as" settings

Date control API

JavaScript API


Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software