How to write only numeric characters on custom field
9 years 11 months ago - 9 years 11 months ago #251799
by lacasetta
my site with Hikashop
www.lacasettabio.it
How to write only numeric characters on custom field was created by lacasetta
-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.2
i have created a custom field:
address > field type TEXT
I'd like that the user can write only numeric characters.
Is there a way to do that?
Thanks a lot
My best regards
-- Joomla version -- : 3.6.2
i have created a custom field:
address > field type TEXT
I'd like that the user can write only numeric characters.
Is there a way to do that?
Thanks a lot
My best regards
my site with Hikashop
www.lacasettabio.it
Last edit: 9 years 11 months ago by lacasetta.
Please Log in or Create an account to join the conversation.
9 years 11 months ago - 9 years 11 months ago #251808
by GW
Replied by GW on topic How to write only numeric characters on custom field
Hi,
there are several options to achieve that, though none are 100% waterproof or work in all browsers.
The easiest solution is to add the attribute type="number" to your custom field, simply go to your custom field page in Hikashop and put that next to the field Attributes.
This should only allow numbers in HTML5 compliant browsers and show the numeric keypad on mobile devices, but for example Firefox still allows you to type letters as well.
If you need a more reliable method, you might need to look at more complex solutions using Javascript I think. If you want to be absolutely sure nothing is submitted in the field except numeric characters, you should always do a server-side check as well. Hikashop allows you to do that with the Regular expression check field. Hope that helps.
Kind regards,
there are several options to achieve that, though none are 100% waterproof or work in all browsers.
The easiest solution is to add the attribute type="number" to your custom field, simply go to your custom field page in Hikashop and put that next to the field Attributes.
This should only allow numbers in HTML5 compliant browsers and show the numeric keypad on mobile devices, but for example Firefox still allows you to type letters as well.
If you need a more reliable method, you might need to look at more complex solutions using Javascript I think. If you want to be absolutely sure nothing is submitted in the field except numeric characters, you should always do a server-side check as well. Hikashop allows you to do that with the Regular expression check field. Hope that helps.
Kind regards,
Last edit: 9 years 11 months ago by GW.
Please Log in or Create an account to join the conversation.
9 years 11 months ago - 9 years 11 months ago #251835
by lacasetta
my site with Hikashop
www.lacasettabio.it
Replied by lacasetta on topic How to write only numeric characters on custom field
Hi, thanks for your help.
Indeed your Type="number" solution work fine only with Crome. It does not work with IE at all and it does not work fine with Firefox.
You can test here www.lacasettabio.it/utente/hikashop-menu...ation/user/form#null
The field is "Partita IVA > inserire ..."
The solution could be also a check or validation with an error message after push the registration button but i don't know if Hikashop has it
Indeed your Type="number" solution work fine only with Crome. It does not work with IE at all and it does not work fine with Firefox.
You can test here www.lacasettabio.it/utente/hikashop-menu...ation/user/form#null
The field is "Partita IVA > inserire ..."
The solution could be also a check or validation with an error message after push the registration button but i don't know if Hikashop has it
my site with Hikashop
www.lacasettabio.it
Last edit: 9 years 11 months ago by lacasetta.
Please Log in or Create an account to join the conversation.
9 years 11 months ago #251843
by GW
Replied by GW on topic How to write only numeric characters on custom field
Hi,
yes, unfortunately there's not really an easy and stable way of only allowing to input numbers, though you can still leave the type="number" as it will be more convenient for mobile users.
I agree that checking after pushing the registration button is the better solution in this case and you can quite easily do that in Hikashop. On your custom field page you can write your own error message that should appear if someone enters something invalid, by typing your message in the Custom error message field.
You then need to tell Hikashop what is a valid input, which you can do in the Regular expression check field. So for example if only numbers are allowed, you could use [0-9]+. If a user then enters something else than a number, you will get the error message. If you need a more advanced check, I would suggest to google "regular expressions" for more information. Hope that helps!
Kind regards,
yes, unfortunately there's not really an easy and stable way of only allowing to input numbers, though you can still leave the type="number" as it will be more convenient for mobile users.
I agree that checking after pushing the registration button is the better solution in this case and you can quite easily do that in Hikashop. On your custom field page you can write your own error message that should appear if someone enters something invalid, by typing your message in the Custom error message field.
You then need to tell Hikashop what is a valid input, which you can do in the Regular expression check field. So for example if only numbers are allowed, you could use [0-9]+. If a user then enters something else than a number, you will get the error message. If you need a more advanced check, I would suggest to google "regular expressions" for more information. Hope that helps!
Kind regards,
The following user(s) said Thank You: nicolas
Please Log in or Create an account to join the conversation.
9 years 11 months ago #251905
by lacasetta
my site with Hikashop
www.lacasettabio.it
Replied by lacasetta on topic How to write only numeric characters on custom field
Hi,
thanks for your help.
But, unfortunatelly, it does not work.
I tryed with
[0-9]+
and with
[0-9]
if I write some alphabeticl characters I don't have warning message.
Could you help me more, please?
Thanks
thanks for your help.
But, unfortunatelly, it does not work.
I tryed with
[0-9]+
and with
[0-9]
if I write some alphabeticl characters I don't have warning message.
Could you help me more, please?
Thanks
my site with Hikashop
www.lacasettabio.it
Please Log in or Create an account to join the conversation.
9 years 11 months ago #251930
by GW
Replied by GW on topic How to write only numeric characters on custom field
Hi,
you mean if you type some letters in your custom field and press the "register" button, the error message does not appear?
Could you show a screenshot of your custom field settings? That would be helpful to see if anything might be wrong.
Also, does an error message appear for other fields, if for example you type an invalid e-mail address or leave it empty and press the register button?
Kind regards,
you mean if you type some letters in your custom field and press the "register" button, the error message does not appear?
Could you show a screenshot of your custom field settings? That would be helpful to see if anything might be wrong.
Also, does an error message appear for other fields, if for example you type an invalid e-mail address or leave it empty and press the register button?
Kind regards,
Please Log in or Create an account to join the conversation.
9 years 11 months ago #251958
by nicolas
Replied by nicolas on topic How to write only numeric characters on custom field
Hi,
The regular expression check will only be done if you turn on the "required" setting of the custom field. So make sure that it is the case.
The regular expression check will only be done if you turn on the "required" setting of the custom field. So make sure that it is the case.
Please Log in or Create an account to join the conversation.
9 years 11 months ago - 9 years 11 months ago #251984
by lacasetta
my site with Hikashop
www.lacasettabio.it
Replied by lacasetta on topic How to write only numeric characters on custom field
Hi,
Indeed the required setting of this field is off.
But i can't turn it on because it is an optional field. It is a field of the VAT and the user can write on it if he wishes the invoice. If he leaves the field empty it means that he does not want the invoice.
Any other solution?
Maybe there is a way to force Hikashop to check the regular expression even with not required fields.
Or, there is a way to integrate Hikashop fields with Breezingform. I use Breezinform and it can check the fields even if they are not required.
Thanks a lot!
To GW, yes the error message system works fine with the other required fields.
Indeed the required setting of this field is off.
But i can't turn it on because it is an optional field. It is a field of the VAT and the user can write on it if he wishes the invoice. If he leaves the field empty it means that he does not want the invoice.
Any other solution?
Maybe there is a way to force Hikashop to check the regular expression even with not required fields.
Or, there is a way to integrate Hikashop fields with Breezingform. I use Breezinform and it can check the fields even if they are not required.
Thanks a lot!
To GW, yes the error message system works fine with the other required fields.
my site with Hikashop
www.lacasettabio.it
Last edit: 9 years 11 months ago by lacasetta.
Please Log in or Create an account to join the conversation.
9 years 11 months ago #252006
by nicolas
Replied by nicolas on topic How to write only numeric characters on custom field
Hi,
If it's the VAT number field, then you can simply turn on the "VAT number check" of the HikaShop configuration. It will check the VAT numbers automatically and make sure that the format of the VAT number correspond to the country the customer selects so it's even better than a regex check. And if there is no VAT number entered by the customer, it won't fail.
If it's the VAT number field, then you can simply turn on the "VAT number check" of the HikaShop configuration. It will check the VAT numbers automatically and make sure that the format of the VAT number correspond to the country the customer selects so it's even better than a regex check. And if there is no VAT number entered by the customer, it won't fail.
Please Log in or Create an account to join the conversation.
9 years 11 months ago #252089
by lacasetta
my site with Hikashop
www.lacasettabio.it
Replied by lacasetta on topic How to write only numeric characters on custom field
That's good!
I did' nt remember that there was a specific check on the vat field! Sorry!
Thanks a lot
Best regards
I did' nt remember that there was a specific check on the vat field! Sorry!
Thanks a lot
Best regards
my site with Hikashop
www.lacasettabio.it
Please Log in or Create an account to join the conversation.
Time to create page: 0.232 seconds