9 2 2 Displaying Validation Errors

LANSA WAM

9.2.2 Displaying Validation Errors

Most modern desktop browsers will display validations errors by displaying a tooltip over the field containing an error message. Usually, only one error is displayed at a time (requiring another submit to check for further errors) and there is no option to display errors at other times, such as during typing or when the user tabs out of the field. At the time of writing, mobile device browsers did not do even this. While they will not allow an invalid form to be submitted, they do not display any errors to explain the problem.

The LANSA framework adds the option of displaying validation errors within the page, usually next to the field. To enable this behavior, you must add the class " lstdErrorShowInDiv" to the page <div> in your layout. The standard shipped layouts do this using the validationErrorDisplay property. You must also provide the <div> tags that will display the error. There must be one error <div> for each field. The <div> must have an ID of "{Field ID}_id" and a class of " lstdFieldError". For example:

<div id=" MyWR_TST_PKD _error" class="lstdFieldError"></div>

The standard field weblets will do this for you via the addErrorDiv property. When the "show in div" behavior is turned off, all error divs are automatically hidden. When the "show in div" behavior is turned on, all error divs are set to invisible, meaning that they cannot be seen by the user but space is still reserved for them in the document. This prevents the confusion of the page re-flowing if they are later made visible. When a validation error occurs in a field the framework will place the error message inside the corresponding error div and make it visible.