Validated Input Values
The validation tab of a component in eForms can be used to determine whether user entries have been done correctly. This tutorial exemplifies using scripting to ensure date fields are entered correctly.
-
Check the property names of the fields that should be used in your script. The property names can be found by opening the field's component for editing, going to the API tab and making a note of the value of the field labeled 'Property Name'.
-
In the Validation tab of a date / time component's settings, set the custom error message you wish to display if the value is not valid. This is done by entering a string of your choice into the field labeled 'Custom Error Message'.
-
Expand the Custom Validation panel and set the validation condition using Javascript. For example, the following script makes sure the start date of an employee's leave is in the future.
Copy// Convert both dates to milliseconds
var date1_ms = Date.parse(data.dayOfLeave1);
var date2_ms = Date.now();
valid = (date1_ms > date2_ms);