Adding validation to an input string component

To add an Input component to your page that allows a user to enter a line of text and have that text validated:
  1. Drag an Input component from the palette onto a Faces JSP.
  2. In the Properties view for the Input component, h:inputText, optionally, change the ID that was automatically generated for the input component and set the style properties and style classes.
  3. From the Format list, select String.
  4. To validate the value entered in this field on the server, click the Validation tab in the Properties view:
    1. To require the user to enter a value, select Value is required.
    2. The validation has two options:
      • Use simple validation - Allows you to set a minimum and maximum number of character values for the input. When submitted to the server, the input is validated to ensure it is within this range. The Constraint drop down allows you select from a predefined set of regular expressions. The default is blank (no constraint). Use the Click to create/edit custom validation code to define a custom regular expression.
      • Use advanced validation - Allows you to define a validation using JSF expression syntax. When defining the constraint you can use standard Javaâ„¢ or JavaScriptâ„¢ regular expression syntax.
    3. Select Display validation error messages in an error message control to automatically create a Display Error component that displays an error message if validation fails on the input component.
    Optionally, select Click to create/edit custom validation code to switch to the Quick Edit view and create custom validation code.
  5. To validate the value entered in this field on the client, click the Behaviour tab in the Properties view:
    1. Select Validate field value in the browser.
    2. On the onblur Actions and onfocus Actions tabs, for On success and On failure select a class for the Apply CSS classes field and select an action from the Run action list.
    Optionally, click Additional behaviors can be supplied in the onsuccess, onerror, onfocussuccess and onfocuserror events in the QuickEdit view to create custom behaviour code.
  6. To prevent input from the user, on the Behavior tab, select Control is disabled or Control is read-only.
  7. To navigate to the next field on the page after the user finishes entering information, select Auto advance to next field. This required that the After user types ___ characters is set.
  8. To restrict the number of characters entered from the client, enter a value in the After user types ___ characters field.
  9. To ensure your component is accessible, you can set a keyboard access key, determine tabbing order, and add a component title. On the Accessibility tab: as an access key (clicking this key at run time causes the component to gain focus), a tabbing order for the component, and a title (which can give the user a tip at run time).
    1. Select a character from the Access key list. Clicking this keyboard key at runtime gives focus to the component.
    2. Type a number for the Tab order index. This number determines where the component is in the tabbing order at runtime.
    3. Type a Title. This value displays with the component at runtime.

Feedback