Forms Support

The Switch component can be easily integrated with HTML5 form as well as KendoReact Form (or other third-party solutions).

The forms supports enables you to validate switch values and prevent the submission of forms which are in an invalid state.

In addition to the exposed form support settings, the Switch provides the same properties and behaves in the same way as a native HTML input[type=checkbox] element.

Functionality and Features

Support for KendoReact Form and Setting Custom Behavior

The KendoReact Form component integrates with all KendoReact components.

You can display error messages and fully customize the behavior of the rendered component by using the additional properties of the Field component.

The following example demonstrates how to render a required custom switch.

Example
View Source
Edit In Stackblitz  
Change Theme:

Setting Validation Requirements

The Switch supports props for setting basic validation requirements. For example, the required property which enables the successful form submission.

Example
View Source
Edit In Stackblitz  
Change Theme:

Setting Custom Validation Messages

You can implement custom error messages which will be displayed if the Switch is not turned on and the user tries to submit the form. To render a custom validation message, set the validationMessage prop.

Example
View Source
Edit In Stackblitz  
Change Theme: