Sign up / login forms

This example demonstrates user authentication forms. Note that this is a demonstration of the forms, not a demonstration of techniques for user management. The login procedure used here is very rudimentary.

Four types of validation

The sign up form contains all four types of validation available within TerraForm:

  1. Datatype validation is used to verify that your email address is valid syntactically using datatype="email";
  2. Built-in rules-based validation is used to ensure that the user name and password are valid using the minlength, maxlength, and pattern attributes. The
    pattern="[[:alnum:]]*([[:alpha:]][[:digit:]]|[[:digit:]][[:alpha:]])[[:alnum:]]*"
    attribute supplied for the password ensures that it is a mixture of letters and digits. Note that the error attribute is supplied here to explain clearly what is wrong with the password or user name.
  3. Custom rules-based validation using the cf_terrarule custom tag is used to ensure the password confirmation matches the password, and to check that the user is not trying to use their user name as their password!
  4. Custom validation using an external template (val_signupform.cfm) looks in the database to see if the user name has been taken already. Notice that if the user name is available, a query in the validation template reserves the name immediately. The reason for this is that to ensure no one else attempts to take the name while the template is processing, the actions of checking availability and assigning the user name must be wrapped within cflock tags. So a placeholder record is actually created within val_signupform.cfm, leaving act_signupform.cfm to fill in the remaining blank fields.

We have also used jsmask to filter invalid key presses for the user name and password. Note that this attribute cannot be relied on to provide any degree of validation as some browsers don't support it. Note the slightly different regular expression format for jsmask as compared to pattern. jsmask is a JavaScript regular expression matching just one character (each key press), while pattern is a ColdFusion regular expression matching the entire string.

Techniques demonstrated