Basically in J! you have some validation predifinde, just like "email", e. g.

[field name="emailFieldName" validation="email" /]

Instead of 'validate="email"' you might need another validation. Maybe you would like to check, if a date is formatted properly. You would do this as follows:

  • Go to your xml and add the "addrulepath" attribute to the form tag:
    • [form addrulepath="/templates/yourTemplate/html/mod_qlform/rules"] - if you put in your template you might edit it via template administration - OR
    • [form addrulepath="/modules/mod_qlform/php/rules"] - only editable by ftp, no access by template, more secure
  • Add the field into your form: [field name="someFieldName" type="text" validation="Xxxxx" /] - ideally you use a more transparent name like "datevalid";-)
  • Add your rule file into this path, code is as follows:
<?php 
defined('_JEXEC') or die;
defined('JPATH_PLATFORM') or die;
class JFormRuleXxxxx extends JFormRule
/**
     * Method to test      *
     * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
     * @param   mixed             $value    The form field value to validate.
     * @param   string            $group    The field name group control value. This acts as as an array container for the field.
     *                                      For example if the field has name="foo" and the group value is set to "bar" then the
     *                                      full field name would end up being "bar[foo]".
     * @param   JRegistry         $input    An optional JRegistry object with the entire data set to validate against the entire form.
     * @param   JForm             $form     The form object for which the field is being tested.
     *
     * @return  boolean  True if the value is valid, false otherwise.
     *
     * @since   11.1
     */
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
    {
        try
        {
            //here check $value
            //if false throw exception
            if(1==2)throw new Exception(JText::_('Some error due to field Xxxxx occurred. Please insert correct syntax.'));
            //if true return true;
        }
        catch (Exception $e)
        {
            JFactory::getApplication()->enqueueMessage($e->getMessage());
            return false;
        }
    }
}