Skip to main content
A validation rule tests what a visitor types into a Short answer field against one format, such as an email address. Without a rule, the field accepts any text, so an entry like name@ or a phone number with letters reaches you unchanged. A rule lets you catch those entries and ask the visitor to correct them. Two settings control a field’s input. Make required forces the visitor to answer, and Validation rule checks the format of that answer. The Validation rule setting appears only after you set Make required to Yes.

Validation rule options

The Validation rule dropdown offers the options below. Choose one option for each field.

Set a validation rule

To require an answer and check its format, follow these steps.
  1. Select a Short answer field, and open Advanced Settings.
  2. Set Make required to Yes. Kameleoon adds an asterisk (*) to the label and shows the Validation rule and Error message settings.
    Short Answer element Advanced Settings, showing Make required set to Yes, Validation rule set to Email, and an Error message field
  3. Select the option in Validation rule that matches the format you expect.
  4. Enter the text for the message that the visitor sees when the value fails the rule in Error message.

Show a message for an invalid value

To place a message beside a field and reveal it only when a value breaks its rule, add a Text element and create a Survey event that shows it.
  1. Add a Text element that contains the message, and place it next to the field.
  2. In the left sidebar, hide the Text element so that it appears only when the event runs.
  3. Click Events in the left sidebar, then click Add event. The Create new event panel lists the event types.
    Create new event panel listing the Click, URL, Display, Survey, Language, and Timer event types
  4. Select Survey, and click Next.
  5. Under If the value for, select the Short answer field.
  6. Under meets the condition, select doesn’t match validation rule.
    New survey event with the condition If the value for Short Answer, and the condition list showing matches validation rule, doesn't match validation rule, is not empty, and only alphanumeric
  7. Under Actions, select Show an element, and choose the Text element.
    New survey event with the condition doesn't match validation rule, and the action Show an element with the element description Text selected
  8. Click Save event.
When the value doesn’t match the rule, the widget shows the message.