Custom Validation

part of a tutorial on the Dynamic Publishing System by Karl Goldstein

The form manager validates submitted form values based on the data type of the element in the form specification. In some cases it is necessary to perform more specialized validation before allowing processing to continue. This lesson shows how to perform custom validation on a form element while using the form manager.

Create the form specification

Copy the form specification created in the first form tutorial lesson (user-add.form) to user-add-state.form.

Add a validate block to the state element like so:

  <validate>
    <condition>
      expr "! [string match [string toupper $value] KS]"
    </condition>
    <message>
      Sorry, residents of KS are not eligible to register.
    </message>
  </validate>

Create the form template

Copy the form template created in the first form tutorial lesson (user-add.adp) to user-add-state.adp.

Try entering KS as the state of residence and submitting the form.

View the form
karlg@arsdigita.com