News:

AbanteCart v1.4.2 is released.

Main Menu

Maximum Length of custom field

Started by David Veganhauser, May 04, 2020, 04:44:11 AM

Previous topic - Next topic

David Veganhauser

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.


David Veganhauser

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?

dvagner

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.

David Veganhauser

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)

dvagner

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">

David Veganhauser

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!

Quote from: dvagner on May 05, 2020, 05:06:43 AM
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">

dvagner

You can change tpl (for custom JS validation) or create extension with hook's to add php validation.

David Veganhauser


Forum Rules Code of conduct
AbanteCart.com 2010 -