Custom Field - Regex Validation
11 years 4 months ago #202745
by gpraceman
Custom Field - Regex Validation was created by gpraceman
-- 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.
-- 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 or Create an account to join the conversation.
11 years 4 months ago #202758
by nicolas
Replied by nicolas on topic Custom Field - Regex Validation
Hi,
That's a good idea. We'll look at adding that capability.
That's a good idea. We'll look at adding that capability.
Please Log in or Create an account to join the conversation.
11 years 3 months ago - 11 years 3 months ago #204408
by gpraceman
Replied by gpraceman on topic Custom Field - Regex Validation
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.
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 3 months ago by gpraceman.
Please Log in or Create an account to join the conversation.
11 years 3 months ago #204430
by gpraceman
Replied by gpraceman on topic Custom Field - Regex Validation
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.
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 or Create an account to join the conversation.
11 years 3 months ago - 11 years 3 months ago #204460
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Custom Field - Regex Validation
Hi,
The regex will be processed by that javascript
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,
The regex will be processed by that javascript
Code:
myregexp = new RegExp(hikashopFieldsJs['regexValueFieldsComp'][type][found]);
if(myregexp.test(elementToCheck.value)){
isValid = true;
}
Also, please make sure that your field is required or the regex check will be skipped.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Last edit: 11 years 3 months ago by nicolas.
Please Log in or Create an account to join the conversation.
11 years 3 months ago #204508
by gpraceman
Replied by gpraceman on topic Custom Field - Regex Validation
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 or Create an account to join the conversation.
11 years 3 months ago #204511
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Custom Field - Regex Validation
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,
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 & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Time to create page: 0.200 seconds