Skip to Content (Press Enter)

This document is a draft, and is designed to show changes from a previous version. It is presently showing added text,changed text,deleted text,[start]/[end] markers,and Issue Numbers.

Hide All Edits   |   Toggle Deletions  |   Toggle Issue Numbers   |   Toggle [start]/[end] Markers   |   Show All Edits

Changes are displayed as follows:

SCR18: Providing client-side validation and alert


Content that validates user input.

This technique relates to:


The objective of this technique is to validate user input as values are entered for each field, by means of client-side scripting. If errors are found, an alert dialog describes the nature of the error in text. Once the user dismisses the alert dialog, it is helpful if the script positions the keyboard focus on the field where the error occurred.


Example 1

The following script will check that a valid date has been entered in the form control.

<label for="date">Date:</label>
<input type="text" name="date" id="date" 
<pre>alert('This control is not a valid date. 
Please re-enter the value.');" /></pre>



For form fields that require specific input:

  1. enter invalid data

  2. determine if an alert describing the error is provided.

Expected Results