- Posts: 28
- Thank you received: 1
How to activate the reg exp validation ?
- plastic1st
-
Topic Author
- Offline
Less
More
10 years 6 months ago #234032
by plastic1st
How to activate the reg exp validation ? was created by plastic1st
-- 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
-- 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 or Create an account to join the conversation.
10 years 6 months ago #234037
by nicolas
Replied by nicolas on topic How to activate the reg exp validation ?
Hi,
Is the field "required" ? The regex will only be used if the field is required.
Is the field "required" ? The regex will only be used if the field is required.
Please Log in or Create an account to join the conversation.
- plastic1st
-
Topic Author
- Offline
Less
More
- Posts: 28
- Thank you received: 1
10 years 6 months ago #234123
by plastic1st
Replied by plastic1st on topic How to activate the reg exp validation ?
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.
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 or Create an account to join the conversation.
10 years 6 months ago #234136
by nicolas
Replied by nicolas on topic How to activate the reg exp validation ?
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 ?
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 or Create an account to join the conversation.
- plastic1st
-
Topic Author
- Offline
Less
More
- Posts: 28
- Thank you received: 1
10 years 6 months ago #234264
by plastic1st
Replied by plastic1st on topic How to activate the reg exp validation ?
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
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.
You'll find attached a screenshot of the custom field.
You can test it here :
s330101700.onlinehome.fr/coopt_v2/entrep...sentation-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.
Please Log in or Create an account to join the conversation.
10 years 6 months ago #234283
by nicolas
Replied by nicolas on topic How to activate the reg exp validation ?
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:
after the code:
in the file administrator/components/com_hikashop/classes/field.php and that should fix the problem.
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(&$field,&$value,$oldvalue){
$status = parent::check($field,$value,$oldvalue);
if($status && $field->field_required && !empty($field->field_options['regex'])){
if(!preg_match('/'.str_replace('/','\/',$field->field_options['regex']).'/',$value)){
$status = false;
if(!empty($this->report)) {
if(!empty($field->field_options['errormessage'])){
$message = $this->trans($field->field_options['errormessage']);
}else{
$message = JText::sprintf('PLEASE_FILL_THE_FIELD', $this->trans($field->field_realname));
}
if($this->report === true) {
$app = JFactory::getApplication();
$app->enqueueMessage($message, 'error');
} else {
$this->parent->messages[] = array(
$message,
'error'
);
}
}
}
}
return $status;
}
Code:
class hikashopText extends hikashopItem {
var $type = 'text';
var $class = 'inputbox';
The following user(s) said Thank You: plastic1st
Please Log in or Create an account to join the conversation.
- plastic1st
-
Topic Author
- Offline
Less
More
- Posts: 28
- Thank you received: 1
10 years 6 months ago #234500
by plastic1st
Replied by plastic1st on topic [SOLVED] How to activate the reg exp validation ?
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 !
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 !
Please Log in or Create an account to join the conversation.
Time to create page: 0.180 seconds