1

I'm try to add my server-side validation for text form field in Joomla 3.4. When I submit form with any empty field message that field is empty appear, but when it not empty submit is working and ignoring email and my own validation. Also email validation work only when I set type="email" but not for type="text". This is what I have:

\components\com_my\models\rules\myrule.xml

<?php
defined('_JEXEC') or die;
jimport('joomla.form.formrule');

class JFormRuleMyrule extends JFormRule
{
    public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null) 
    {
        return false;
    }
}

\components\com_my\models\forms\form.xml

<form>
    <fieldset name="default" addrulepath="/components/com_my/models/rules" label="My form">
        <field
            name="user"
            type="text"
            label="Label"
            message="Message"
            required="true"
            size="10"
            maxsize="10"
            validate="myrule"
        />
        <field
            name="mail"
            type="text"
            label="Label"
            message="Message"
            required="true"
            validate="email"
        />
    </fieldset>
</form>

Will be glad to get any help about this! Thank you!

CodeBy
  • 714
  • 4
  • 10
  • 25
  • I'm a little confused about what exactly is happening. Can you give an example of an email that you think should not validate? It is much trickier than you might think since the Joomla validation will work if you are emailing to an account on the same server and so on. There are many more valid emails than you might think. – Elin Nov 14 '15 at 23:32

0 Answers0