Jump to content
thirty bees forum

Custom validator


musicmaster

Recommended Posts

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:

address2.jpg.87aebeef60b4238bc90e04de1e2e1394.jpg

What is going wrong here. And what can I do to have a custom validation?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...