Client-side validation ensures that user inputs are validated before a form is submitted, so that users receive immediate feedback on their errors. Client-side validation simplifies your application by preventing users from entering invalid data. For example, if a user is completing a form and enters a string or decimal in a quantity field that is set to accept only integers, an error message is displayed before the user submits the form. Client-side validation can occur on both a value that is received from an external system and on a property for which users enter data on a form.
- Select the Enable Client Side Validation check box on the Advanced tab of the Harness form on which the property requiring validation appears.
- Create a custom edit validate rule (Rule-File-Text rule type) so that you can define a Java routine that tests the validity of a data entry value.
Creating the script
- Open the harness that contains the field that you want to validate, and then click the Advanced tab. By default, the client-side validation is enabled on all forms, so the fields that use edit validate rules are validated before the form is submitted. If client-side validation is not enabled in the current harness, select the Enable client side validation check box.
- Click the Scripts & Styles tab, and select from the menu.
- Add the validation script to the text file rule. You can also upload a text file directly to the text file rule.
- Save and close the text file. It is now associated with the harness by the reference on the Scripts & Styles tab.
Adding the script to a control