Client and Server side validations for EJ Form controls:
The list of form controls available in the Essential Studio are as follows:
You can add both client-side and server-side validations for these components. The following section explains how to achieve this.
To add client side validation:
An inbuilt jQuery validation support is available for the form controls. jQuery validation can be achieved via ValidationRules and ValidationMessage properties. The ValidationRules property is used to define the jQuery validate rules for the control and ValidationMessage is used to define the respective error message for the rules that are specified in the ValidationRules property. When error message is not specified to the validation rules, it takes the default validation error message. The ValidationRules and ValidationMessage properties work within a form element, but otherwise it does not work. Before using those properties, you need to add the jQuery validate plugin (jquery.validate.min.js) to your application. This is showcased in the following code example.
You can get the HTML 5 validation in the component with help of the HtmlAttributes API. This API is used to add the HTML attributes to the respective elements. The HtmlAttributes is not only for HTML 5 validation, but it can also add the list of possible HTML attributes to the element. This is demonstrated in the following code example.
Server Side Validation:
You can set the validation for the EJ Form control in the form post back by using the server-side validation. Follow the steps to achieve this.
ModelState.isValid returns false when the input data is not valid, otherwise it returns true.
The following code examples displays the same.
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|
or the page will be automatically redirected to sign-in page in 10 seconds.