Account services

Form validation example

This form is a fully functioning example of form validation and display of error messages.

Want to join?

Press shift-key to select more than one

How is it done?

The REQUEST-method is used to determine whether the form has been submitted. If it is GET, then the form is seen for the first time, and no error messages are displayed. Otherwise the fields are validated in a script that returns an associative array (in Python called dictionary), which contains error messages keyed form field. If a field has an error, the class="error" is added to the <input/> element and a <div class="error-hint"> with the error message is placed after.