Adding a field-level On Validate event
-
To add a TextBox control to the workspace:
- In the Controls Toolbox, click to select the TextBox control.
- Click anywhere inside the workspace to paste the TextBox control.
-
To change the Name value of the TextBox control:
-
In the Property Inspector, click the
Value field next to
the Property: Name.
The Text box is displayed.
- In the Text window, specify txtQuantity.
-
Click
OK.
The Text window closes.
-
In the Property Inspector, click the
Value field next to
the Property: Name.
-
To add a Label control to the workspace:
- In the Controls Toolbox, click to select the Label control.
- Click anywhere inside the workspace to paste the Label control.
-
To change the Caption of the Label control:
-
In the Property Inspector, click the Value field next to the
Property: Caption.
The Text window is displayed.
- Specify Quantity:.
-
Click
OK.
The Text window closes.
-
In the Property Inspector, click the Value field next to the
Property: Caption.
-
Click and drag to move and resize the TextBox and Label boxes
until they appear like the following:
-
To assign the On validate Property to the txtQuantity TextBox:
- Click to highlight the txtQuantity TextBox.
- In the Property Inspector, click the Value field next to the Property: On validate Property.
-
Click the browse button.
The Javascript window is displayed.
-
Specify the following code in the JavaScript window:
-
Click
OK.
The Form Builder screen is displayed.
Additional code can be added to prevent the user from moving from this field until a valid input is entered. This example for enhanced JavaScript sets the “focus” of this form back to the txtQuantity TextBox if an error condition exists:
Note: In the JavaScript window, click Help for detailed descriptions of the variables for each expression.