[Skip to main content](#vessel-content)

#   How to activate the reg exp validation ?

##

- **[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")**
- [![plastic1st's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31031-plastic1st "View plastic1st's Profile") Topic Author
- [ Offline](/forum/user/31031-plastic1st)

Less More

- Posts: 28
- Thank you received: 1
-
-

10 years 7 months ago [\#234032](#234032) by [plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")  *[How to activate the reg exp validation ?](/forum/28-shipping-methods/883284-how-to-activate-the-reg-exp-validation#234032 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5 -- Browser(s) name and version -- : Firefox 45.0.1  Hi.  I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format. I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters). Is there someting I'm missing (like an option to activate), to get the RegExp work ?  Thanks in advance for your help  plastic1st")* was created by *[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")*

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.5
-- Browser(s) name and version -- : Firefox 45.0.1

Hi.

I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format.
I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters).
Is there someting I'm missing (like an option to activate), to get the RegExp work ?

Thanks in advance for your help

plastic1st

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgzMjg0LWhvdy10by1hY3RpdmF0ZS10aGUtcmVnLWV4cC12YWxpZGF0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86555
- Thank you received: 14304
-
-

10 years 7 months ago [\#234037](#234037) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to activate the reg exp validation ?](/forum/28-shipping-methods/883284-how-to-activate-the-reg-exp-validation#234037 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5 -- Browser(s) name and version -- : Firefox 45.0.1  Hi.  I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format. I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters). Is there someting I'm missing (like an option to activate), to get the RegExp work ?  Thanks in advance for your help  plastic1st")*

Hi,

Is the field "required" ? The regex will only be used if the field is required.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgzMjg0LWhvdy10by1hY3RpdmF0ZS10aGUtcmVnLWV4cC12YWxpZGF0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")**
- [![plastic1st's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31031-plastic1st "View plastic1st's Profile") Topic Author
- [ Offline](/forum/user/31031-plastic1st)

Less More

- Posts: 28
- Thank you received: 1
-
-

10 years 7 months ago [\#234123](#234123) by [plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")  Replied by *[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")* on topic *[How to activate the reg exp validation ?](/forum/28-shipping-methods/883284-how-to-activate-the-reg-exp-validation#234123 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5 -- Browser(s) name and version -- : Firefox 45.0.1  Hi.  I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format. I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters). Is there someting I'm missing (like an option to activate), to get the RegExp work ?  Thanks in advance for your help  plastic1st")*

Hello Nicolas.

Thanks for your answer.
The field is required. If I let it empty, the field control is done, and I get an error message.
Only the RegExp does not work.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgzMjg0LWhvdy10by1hY3RpdmF0ZS10aGUtcmVnLWV4cC12YWxpZGF0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86555
- Thank you received: 14304
-
-

10 years 7 months ago [\#234136](#234136) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to activate the reg exp validation ?](/forum/28-shipping-methods/883284-how-to-activate-the-reg-exp-validation#234136 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5 -- Browser(s) name and version -- : Firefox 45.0.1  Hi.  I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format. I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters). Is there someting I'm missing (like an option to activate), to get the RegExp work ?  Thanks in advance for your help  plastic1st")*

Hi,

Then it's probably that the regex you put there is wrong. Could you do a screenshot of the settings of your custom field and provide a link to the page where it is displayed ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgzMjg0LWhvdy10by1hY3RpdmF0ZS10aGUtcmVnLWV4cC12YWxpZGF0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")**
- [![plastic1st's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31031-plastic1st "View plastic1st's Profile") Topic Author
- [ Offline](/forum/user/31031-plastic1st)

Less More

- Posts: 28
- Thank you received: 1
-
-

10 years 7 months ago [\#234264](#234264) by [plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")  Replied by *[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")* on topic *[How to activate the reg exp validation ?](/forum/28-shipping-methods/883284-how-to-activate-the-reg-exp-validation#234264 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5 -- Browser(s) name and version -- : Firefox 45.0.1  Hi.  I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format. I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters). Is there someting I'm missing (like an option to activate), to get the RegExp work ?  Thanks in advance for your help  plastic1st")*

I've tried different RegExps, including RegExps found on the forum, but none of these did work.
You'll find attached a screenshot of the custom field.

You can test it here :
[ s330101700.onlinehome.fr/coopt\_v2/entrep...sentation-des-offres](http://s330101700.onlinehome.fr/coopt_v2/entreprises/presentation-des-offres)
Click on an image to select an offer and get redirected to the cart.
You need to login to test the field.

I send you login/password on PM.

- [ ![Picture1.png](/forum/attachment/30299) ](/forum/attachment/30299 "Picture1.png") [ ](/forum/attachment/30299?download=1 "Picture1.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgzMjg0LWhvdy10by1hY3RpdmF0ZS10aGUtcmVnLWV4cC12YWxpZGF0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86555
- Thank you received: 14304
-
-

10 years 7 months ago [\#234283](#234283) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to activate the reg exp validation ?](/forum/28-shipping-methods/883284-how-to-activate-the-reg-exp-validation#234283 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5 -- Browser(s) name and version -- : Firefox 45.0.1  Hi.  I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format. I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters). Is there someting I'm missing (like an option to activate), to get the RegExp work ?  Thanks in advance for your help  plastic1st")*

Hi,

The problem is that the regex on the custom address fields are not handled properly for the address edition when using the another address selector than the popup one, which is the case on your website.
Add the code: Code:

function check(&amp;$field,&amp;$value,$oldvalue){ $status = parent::check($field,$value,$oldvalue); if($status &amp;&amp; $field-&gt;field_required &amp;&amp; !empty($field-&gt;field_options['regex'])){ if(!preg_match('/'.str_replace('/','\/',$field-&gt;field_options['regex']).'/',$value)){ $status = false; if(!empty($this-&gt;report)) { if(!empty($field-&gt;field_options['errormessage'])){ $message = $this-&gt;trans($field-&gt;field_options['errormessage']); }else{ $message = JText::sprintf('PLEASE_FILL_THE_FIELD', $this-&gt;trans($field-&gt;field_realname)); } if($this-&gt;report === true) { $app = JFactory::getApplication(); $app-&gt;enqueueMessage($message, 'error'); } else { $this-&gt;parent-&gt;messages[] = array( $message, 'error' ); } } } } return $status; }

after the code: Code:

class hikashopText extends hikashopItem { var $type = 'text'; var $class = 'inputbox';

in the file administrator/components/com_hikashop/classes/field.php and that should fix the problem.

The following user(s) said Thank You: [plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgzMjg0LWhvdy10by1hY3RpdmF0ZS10aGUtcmVnLWV4cC12YWxpZGF0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")**
- [![plastic1st's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31031-plastic1st "View plastic1st's Profile") Topic Author
- [ Offline](/forum/user/31031-plastic1st)

Less More

- Posts: 28
- Thank you received: 1
-
-

10 years 7 months ago [\#234500](#234500) by [plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")  Replied by *[plastic1st](/forum/user/31031-plastic1st "View plastic1st's Profile")* on topic *[\[SOLVED\] How to activate the reg exp validation ?](/forum/28-shipping-methods/883284-how-to-activate-the-reg-exp-validation#234500 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5 -- Browser(s) name and version -- : Firefox 45.0.1  Hi.  I want to add a RegExp on the postcode, using a custom field, to match the french postal codes format. I've set the RegExp in my custom field, but it doesn't work (the form is validated, even if I key in unauthorized characters). Is there someting I'm missing (like an option to activate), to get the RegExp work ?  Thanks in advance for your help  plastic1st")*

Hello Nicolas.

Sorry for the long time before answering... I had no access to the Internet during the week end.

Thank you very much for your help.
It works like a charm ! ![:cheer:](/media/kunena/emoticons/2.png ":cheer:")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgzMjg0LWhvdy10by1hY3RpdmF0ZS10aGUtcmVnLWV4cC12YWxpZGF0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.127 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
