Adding a field-level On Validate event

  1. To add a TextBox control to the workspace:
    1. In the Controls Toolbox, click to select the TextBox control.
    2. Click anywhere inside the workspace to paste the TextBox control.
  2. To change the Name value of the TextBox control:
    1. In the Property Inspector, click the Value field next to the Property: Name.
      The Text box is displayed.
    2. In the Text window, specify txtQuantity.
    3. Click OK.
      The Text window closes.
  3. To add a Label control to the workspace:
    1. In the Controls Toolbox, click to select the Label control.
    2. Click anywhere inside the workspace to paste the Label control.
  4. To change the Caption of the Label control:
    1. In the Property Inspector, click the Value field next to the Property: Caption.
      The Text window is displayed.
    2. Specify Quantity:.
    3. Click OK.
      The Text window closes.
  5. Click and drag to move and resize the TextBox and Label boxes until they appear like the following:


  6. To assign the On validate Property to the txtQuantity TextBox:
    1. Click to highlight the txtQuantity TextBox.
    2. In the Property Inspector, click the Value field next to the Property: On validate Property.
    3. Click the browse button.
      The Javascript window is displayed.
    4. Specify the following code in the JavaScript window:


  7. 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.