Being developers, we should provide an efficient interface to validate all information. Sitecore provides out-of-the-box validators that work both on the client side and server side, and also flexibility to create our own custom validators.
In this recipe, we will create an Employee Information
form. Here, we will use some out-of-the-box validators to validate the required field, integer, and email. We will also create a custom validator to validate Employee Joining Date
and Relieving Date
.
We will first create a template with the required fields to achieve this recipe:
Create an
Employee
template with fields such asEmployee ID
,Employee Name
,Email Address
,Date of Joining
, andDate of Relieving
.Now we will assign some out-of-the-box validators to some fields. From the field editor, select the Employee ID field in the Validation Rules section. In the Validator Bar field, select the Required and Is Integer field rules, as shown in...