Client-side form validation

From Joomla! Documentation

Revision as of 05:10, 7 April 2008 by E-builds (talk | contribs) (Creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Intro[edit]

Joomla 1.5 contains a behavior JHTMLBehavior::formvalidation() which enables the script validate.js. It uses mootools (I think) and allows your form and its elements to be validated. The only thing you have to do is set the classes of the form to specified meanings such as

  • required
  • username
  • password
  • numeric
  • email

To enable the validation[edit]

I believe the only thing to do is set the class "form-validate" to the form.


TODO[edit]

  • There should be a way to not let your form be submitted in case the javascript isn't loaded or contains an error.

How to do this? Is this done by giving a token to the script receving the form?

  • How to add your own custom form validators? setHandler? If so, how to enable this via Joomla (should this be in the html header??