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

#   regex validations

##

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

Less More

- Posts: 126
- Thank you received: 2
-
-

15 years 6 months ago [\#15500](#15500) by [mett](/forum/user/1080-mett "View mett's Profile")  *[regex validations](/forum/4-how-to/15500-regex-validations#15500 "Hello,  I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^&#91;0-9&#93;{9}$/ (format 723456789).")* was created by *[mett](/forum/user/1080-mett "View mett's Profile")*

Hello,

I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^[0-9]{9}$/ (format 723456789).

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE1NTAwLXJlZ2V4LXZhbGlkYXRpb25zP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86323
- Thank you received: 14283
-
-

15 years 6 months ago [\#15505](#15505) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: regex validations](/forum/4-how-to/15500-regex-validations#15505 "Hello,  I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^&#91;0-9&#93;{9}$/ (format 723456789).")*

Hi,

What you can do is override the hikashopCheckChangeForm javascript function located in media/com_hikashop/js/hikashop.js in a js file of your template loaded AFTER that file and change the regex in it so that it checks for the number of characters.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE1NTAwLXJlZ2V4LXZhbGlkYXRpb25zP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

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

Less More

- Posts: 126
- Thank you received: 2
-
-

15 years 6 months ago [\#15595](#15595) by [mett](/forum/user/1080-mett "View mett's Profile")  Replied by *[mett](/forum/user/1080-mett "View mett's Profile")* on topic *[Re: regex validations](/forum/4-how-to/15500-regex-validations#15595 "Hello,  I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^&#91;0-9&#93;{9}$/ (format 723456789).")*

Can be done in an easy way? ![:)](/media/kunena/emoticons/3.png ":)") For example, another box for each field where i can add some validations (like fabrik component for example)?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE1NTAwLXJlZ2V4LXZhbGlkYXRpb25zP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86323
- Thank you received: 14283
-
-

15 years 6 months ago [\#15596](#15596) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: regex validations](/forum/4-how-to/15500-regex-validations#15596 "Hello,  I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^&#91;0-9&#93;{9}$/ (format 723456789).")*

It would be nice indeed. We can add that as a feature request. However, it's not possible on the current version where only the solution above is.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE1NTAwLXJlZ2V4LXZhbGlkYXRpb25zP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

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

Less More

- Posts: 27
- Thank you received: 0
-
-

14 years 7 months ago [\#43176](#43176) by [justaguy](/forum/user/6149-justaguy "View justaguy's Profile")  Replied by *[justaguy](/forum/user/6149-justaguy "View justaguy's Profile")* on topic *[Re: regex validations](/forum/4-how-to/15500-regex-validations#43176 "Hello,  I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^&#91;0-9&#93;{9}$/ (format 723456789).")*

Thanks for that info, works great for phone and other validation you already built for, but what about custom fields?
I have an address password custom field, that should only take numbers.
I have changed the phone filter validation and added some code to the if(type=='address') element like this: Code:

else if(type=='address'){ if(typeof varform.elements['data[address][address_telephone]'] != 'undefined'){ var phoneField = varform.elements['data[address][address_telephone]']; if(phoneField){ phoneField.value = phoneField.value.replace(/ /g,""); if(phoneField.value.length &gt; 0){ var filter = /^[0-9]+$/i; if( !filter.test(phoneField.value)){ alert(hikashop['valid_phone']); return false; } } } } //added code for address password validation else if(typeof varform.elements['data[address][address_password]'] != 'undefined'){ var codeField = varform.elements['data[address][address_password]']; var filter = /^[0-9]+$/i; if( !filter.test(codeField.value)){ alert(hikashop['valid_code']); return false; } } }

but this code doesn't work for me.
could you please help on that?
Thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE1NTAwLXJlZ2V4LXZhbGlkYXRpb25zP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

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

Less More

- Posts: 27
- Thank you received: 0
-
-

14 years 7 months ago -  14 years 7 months ago [\#43179](#43179) by [justaguy](/forum/user/6149-justaguy "View justaguy's Profile")  Replied by *[justaguy](/forum/user/6149-justaguy "View justaguy's Profile")* on topic *[Re: regex validations](/forum/4-how-to/15500-regex-validations#43179 "Hello,  I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^&#91;0-9&#93;{9}$/ (format 723456789).")*

never mind, silly me, just removed the else from my statement and left only the if syntax and it's working...
would love to know how to implement this hikashop); in my language file...

Last edit: 14 years 7 months ago by [justaguy](/forum/user/6149-justaguy "View justaguy's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE1NTAwLXJlZ2V4LXZhbGlkYXRpb25zP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86323
- Thank you received: 14283
-
-

14 years 7 months ago [\#43301](#43301) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: regex validations](/forum/4-how-to/15500-regex-validations#43301 "Hello,  I'm looking for a way to add some validations to custom fields. For example, i need that phone number field to have 9 characters: /^&#91;0-9&#93;{9}$/ (format 723456789).")*

What you should do is set an error message in your custom field options.
Then, you can use joomfish/falang to translate the custom field error message.
Finally, in your code, you can use instead:
hikashop

which will contain the error message of the field address_password.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE1NTAwLXJlZ2V4LXZhbGlkYXRpb25zP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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.059 seconds

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