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

#   Custom Field - Regex Validation

##

- **[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")**
- [![gpraceman's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37240.png)](/forum/user/37240-gpraceman "View gpraceman's Profile") Topic Author
- [ Offline](/forum/user/37240-gpraceman)

Less More

- Posts: 166
- Thank you received: 11
-
- [](http://grandprix-software-central.com)
-

11 years 5 months ago [\#202745](#202745) by [gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")  *[Custom Field - Regex Validation](/forum/2-general-talk-about-hikashop/877156-custom-field-regex-validation#202745 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.39  It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.")* was created by *[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")*

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.4.39

It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzg3NzE1Ni1jdXN0b20tZmllbGQtcmVnZXgtdmFsaWRhdGlvbj90bXBsPW1hcmtkb3du) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

11 years 5 months ago [\#202758](#202758) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom Field - Regex Validation](/forum/2-general-talk-about-hikashop/877156-custom-field-regex-validation#202758 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.39  It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.")*

Hi,

That's a good idea. We'll look at adding that capability.

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

- **[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")**
- [![gpraceman's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37240.png)](/forum/user/37240-gpraceman "View gpraceman's Profile") Topic Author
- [ Offline](/forum/user/37240-gpraceman)

Less More

- Posts: 166
- Thank you received: 11
-
- [](http://grandprix-software-central.com)
-

11 years 4 months ago -  11 years 4 months ago [\#204408](#204408) by [gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")  Replied by *[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")* on topic *[Custom Field - Regex Validation](/forum/2-general-talk-about-hikashop/877156-custom-field-regex-validation#204408 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.39  It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.")*

I appreciate you adding in this capability with 2.5.0, however, I cannot get it to work. I changed my custom field from Text to Custom Text, put in the regex and saved. Now there is no textbox for the customer to enter a value into and the product cannot be added to the shopping cart. Only the field label and the asterisk is shown. I cannot even revert the field back to Text, as that dropdown is not shown anymore for that field.

EDIT: Actually the product was added to the cart, but there was not the usual add to cart notice. There was also no warning about an invalid entry. Since there is no textbox, and thus no value entered, I would have expected some validation error being shown, but there wasn't.

Last edit: 11 years 4 months ago by [gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile").

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

- **[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")**
- [![gpraceman's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37240.png)](/forum/user/37240-gpraceman "View gpraceman's Profile") Topic Author
- [ Offline](/forum/user/37240-gpraceman)

Less More

- Posts: 166
- Thank you received: 11
-
- [](http://grandprix-software-central.com)
-

11 years 4 months ago [\#204430](#204430) by [gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")  Replied by *[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")* on topic *[Custom Field - Regex Validation](/forum/2-general-talk-about-hikashop/877156-custom-field-regex-validation#204430 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.39  It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.")*

OK, I've got the field back to a text entry, but I had to change the field type in the database. I have my regex entered, but the validation fails, even for a valid entry.

My regex is: /[A-Z]{4}[0-9]+-[A-Z0-9]{4}-[A-Z0-9]{5}-[A-Z0-9]{4}-[A-Z0-9]{4}/i

A value of XXXX14-123D-E1234-567T-435H should be accepted, but fails validation. I ran the regex through an online tester and the regex worked as expected.

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

11 years 4 months ago -  11 years 4 months ago [\#204460](#204460) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Custom Field - Regex Validation](/forum/2-general-talk-about-hikashop/877156-custom-field-regex-validation#204460 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.39  It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.")*

Hi,

The regex will be processed by that javascript Code:

myregexp = new RegExp(hikashopFieldsJs['regexValueFieldsComp'][type][found]); if(myregexp.test(elementToCheck.value)){ isValid = true; }

which means that you have to specify your regex without delimiters (your "/") and without the flags (your "i").

Also, please make sure that your field is required or the regex check will be skipped.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Last edit: 11 years 4 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

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

- **[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")**
- [![gpraceman's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37240.png)](/forum/user/37240-gpraceman "View gpraceman's Profile") Topic Author
- [ Offline](/forum/user/37240-gpraceman)

Less More

- Posts: 166
- Thank you received: 11
-
- [](http://grandprix-software-central.com)
-

11 years 4 months ago [\#204508](#204508) by [gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")  Replied by *[gpraceman](/forum/user/37240-gpraceman "View gpraceman's Profile")* on topic *[Custom Field - Regex Validation](/forum/2-general-talk-about-hikashop/877156-custom-field-regex-validation#204508 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.39  It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.")*

Thanks, I got it working. It would be nice if when a new version is released if it included updated documentation. I see nothing about the regex feature in the current documentation.

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

11 years 4 months ago [\#204511](#204511) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Custom Field - Regex Validation](/forum/2-general-talk-about-hikashop/877156-custom-field-regex-validation#204511 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.39  It would be great if we were able to add a custom text field and be able to apply regex validation. Just making the field required doesn't prevent the customer from entering incorrect information.")*

Hi,

HikaShop 2.5.0 is release but the automatic update is not activated.
We should update the documentation after the "final" release of HikaShop 2.5

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzg3NzE1Ni1jdXN0b20tZmllbGQtcmVnZXgtdmFsaWRhdGlvbj90bXBsPW1hcmtkb3du) 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.187 seconds

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

[](#top)
