Force Custom Text field to uppercase
- nevillematthews
-
Topic Author
- Offline
Less
More
6 years 14 hours ago #324457
by nevillematthews
Force Custom Text field to uppercase was created by nevillematthews
-- url of the page with the problem -- :
www.mathost3.co.uk/lou4
-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.3.21
-- Browser(s) name and version -- : Firefox Developer 82.0b5(64-bit)
Hi
How do I force a Custom Text field to uppercase?
I don't really want to use Regex as this only reports an error, I would like the field to just save to uppercase but preferably only show upper case when typing.
Thank you
Neville Matthews
-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.3.21
-- Browser(s) name and version -- : Firefox Developer 82.0b5(64-bit)
Hi
How do I force a Custom Text field to uppercase?
I don't really want to use Regex as this only reports an error, I would like the field to just save to uppercase but preferably only show upper case when typing.
Thank you
Neville Matthews
Please Log in or Create an account to join the conversation.
6 years 2 hours ago #324470
by nicolas
Replied by nicolas on topic Force Custom Text field to uppercase
Hi,
You can add CSS code for that using text-transform: uppercase; on the input field so that the text appears uppercase in the input field.
Now with that, the text will appear uppercase in the input but won't be saved as uppercase.
You would need to also either:
- add a similar CSS to the area where the value is used to have it appear as uppercase
- add some javascript to the page where you have the input to force the uppercase while the text is being typed
Now a simpler approach would be to force uppercase with the pattern attribute in your custom field:
pattern="[A-Z]*"
Here is a page which discuss the different solutions:
www.the-art-of-web.com/html/input-field-uppercase/
You can add CSS code for that using text-transform: uppercase; on the input field so that the text appears uppercase in the input field.
Now with that, the text will appear uppercase in the input but won't be saved as uppercase.
You would need to also either:
- add a similar CSS to the area where the value is used to have it appear as uppercase
- add some javascript to the page where you have the input to force the uppercase while the text is being typed
Now a simpler approach would be to force uppercase with the pattern attribute in your custom field:
pattern="[A-Z]*"
Here is a page which discuss the different solutions:
www.the-art-of-web.com/html/input-field-uppercase/
Please Log in or Create an account to join the conversation.
- nevillematthews
-
Topic Author
- Offline
5 years 11 months ago #325152
by nevillematthews
Replied by nevillematthews on topic Force Custom Text field to uppercase
Hi Nicolas
when I enter exactly this --> pattern="[A-Z]*" including the quotes in the Custom Field "Attributes" field and try to save it I get the following error message:-
Error Saving
Please specify a correct attribute
Thank you
Neville Matthews
when I enter exactly this --> pattern="[A-Z]*" including the quotes in the Custom Field "Attributes" field and try to save it I get the following error message:-
Error Saving
Please specify a correct attribute
Thank you
Neville Matthews
Please Log in or Create an account to join the conversation.
5 years 11 months ago #325154
by nicolas
Replied by nicolas on topic Force Custom Text field to uppercase
Hi,
I think that the issue is that the star character has not been authorized.
Change the line:
to:
in the file administrator/components/com_hikashop/classes/field.php and try again. It should let you do it then.
I think that the issue is that the star character has not been authorized.
Change the line:
Code:
if(!preg_match('#^([a-z0-9_-]+ *= *"[\p{L}\p{N}\p{Z}\p{S}\p{M} :\-;\(\)\{\}\[\]\']+" *)* *$#i', $fieldOptions['attribute'])){
Code:
if(!preg_match('#^([a-z0-9_-]+ *= *"[\p{L}\p{N}\p{Z}\p{S}\p{M} \+\*:\-;\(\)\{\}\[\]\']+" *)* *$#i', $fieldOptions['attribute'])){
Please Log in or Create an account to join the conversation.
Time to create page: 0.163 seconds