AbanteCart Community
Shopping Cart Operations => Support => General Support => Topic started by: David Veganhauser on May 04, 2020, 04:44:11 AM
-
Hello,
Is there a way I can limit the number of characters for a custom field that I have added to my form?
For instance, can I limit this field shown to 100 characters?
Thank you in advance.
-
Hello. Fill the regex pattern https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s09.html
-
Hi, I went to the page and looked over the article. It was a bit confusing as it was not specific enough for me to follow (sorry)
So I tried this
/^.{1,100}$/
And it doesnt work
Ideas?
-
I try your regex - they work fine.
Provide more information: Abantecart Version, browsers for test, have you errors in browser console? errors in abantecart log or php? etc.
-
Hi, thanks for your reply
I was not getting errors, just nothing was happening. I could keep typing and I got no message. Maybe I have just not implemented it correctly? see the screenshot I have posted below
AbanteCart Version 1.2.15
Google Chrome Version 81.0.4044.129 (Official Build) (64-bit)
-
Verify start after click on "Add to Cart"
On typing used html attribute 'pattern'
<input type="text" name="option[354]" id="option354" value="" placeholder="" class="form-control " data-attribute-value-id="" pattern="^.{1,100}$" title="Some error text">
-
Thank you for writing me back.. I understand html and css, but in the context of using AbanteCart or other layers like this, I admit I am lost since I have never worked with them before.
I do not see an element type that allows me to write a custom piece of html. Are you saying I should modify the tpl file? Sorry for the stupid questions in advance!
Verify start after click on "Add to Cart"
On typing used html attribute 'pattern'
<input type="text" name="option[354]" id="option354" value="" placeholder="" class="form-control " data-attribute-value-id="" pattern="^.{1,100}$" title="Some error text">
-
You can change tpl (for custom JS validation) or create extension with hook's to add php validation.
-
THank you for your reply!