You can use regular expressions to validate input in HTML interactive output.

This page provides an example of the validation code as well as commonly used regular expressions.

Input Validation

The following JavaScript example can be used to validate an input format:
3 char – 3 digits. For example ABC-123 .

If the input does not match the required format a message appears and after clicking OK, the field is colored red.

If a user deletes the input, the background color of the field return to grey.

Note that a field can also be mandatory. For more information see Editing Text Options in Editing Interactive Elements.

You can experience using this JavaScript for input validation in Experience Docomotion  – Sample Customer Satisfaction Form.
var regex = /^[A-Za-z]{3}-[0-9]{3}$/;
if (this.value!= "" && !regex.test(this.value))
  if (document.getElementsByName( != null)
      document.getElementsByName([0].style.background = "red";
      alert('Enter Valid Code: ABC-123');
 document.getElementsByName([0].style.background = "#C0C0C0";}

Examples of Regular Expressions

Following are a few examples of common regular expressions.

1. Number – the input is a number

2. Number within a range – Limit to 45 digits

3. Only text

4. Find specific text in a string – Look for first* or second*, “firsts” also matches

5. Length does not exceed X characters

  • 3 to 7 characters:
  • Exactly 7 characters
  • Minimum 3 characters:

6. Match date in format of: XX/XX/YYYY

7. Valid email

Note that Docomotion provides a predefined script for validating email addresses.