Once under Prestashop I built a custom validation routine for the address2 field of the customer registration form. It was quite simple:
In classes/Address.php I gave address2 it own validation routine (in the original it uses isAddress:
'address1' => ['type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128],
'address2' => ['type' => self::TYPE_STRING, 'validate' => 'isAddress2', 'size' => 128],`
address2() was then declared in classes/Validation.php.
public static function isAddress2($address)
{
return empty($address) || preg_match(Tools::cleanNonUnicodeSupport('/^[^!<>?=+@{}_$%]+$/u'), $address);
}
However, this doesn't work with Thirty Bees. I get a javascript error as soon as I add some content in the address2 field. The strange thing is that it doesn't even make an ajax call. The error (in js/validate.js) I get looks so:
What is going wrong here. And what can I do to have a custom validation?