Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: Maximum Length of custom field  (Read 3532 times)

Offline David Veganhauser

  • Newbie
  • *
  • Posts: 32
  • Karma: +4/-0
    • View Profile
Maximum Length of custom field
« 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.

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile

Offline David Veganhauser

  • Newbie
  • *
  • Posts: 32
  • Karma: +4/-0
    • View Profile
Re: Maximum Length of custom field
« Reply #2 on: May 04, 2020, 10:57:50 AM »
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?

Offline dvagner

  • Core/UI Developer
  • Jr. Member
  • **
  • Posts: 73
  • Karma: +28/-1
    • View Profile
Re: Maximum Length of custom field
« Reply #3 on: May 05, 2020, 02:22:09 AM »
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.

Offline David Veganhauser

  • Newbie
  • *
  • Posts: 32
  • Karma: +4/-0
    • View Profile
Re: Maximum Length of custom field
« Reply #4 on: May 05, 2020, 03:27:57 AM »
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)

Offline dvagner

  • Core/UI Developer
  • Jr. Member
  • **
  • Posts: 73
  • Karma: +28/-1
    • View Profile
Re: Maximum Length of custom field
« Reply #5 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">

Offline David Veganhauser

  • Newbie
  • *
  • Posts: 32
  • Karma: +4/-0
    • View Profile
Re: Maximum Length of custom field
« Reply #6 on: May 05, 2020, 06:15:55 AM »
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">

Offline dvagner

  • Core/UI Developer
  • Jr. Member
  • **
  • Posts: 73
  • Karma: +28/-1
    • View Profile
Re: Maximum Length of custom field
« Reply #7 on: May 06, 2020, 03:09:57 AM »
You can change tpl (for custom JS validation) or create extension with hook's to add php validation.

Offline David Veganhauser

  • Newbie
  • *
  • Posts: 32
  • Karma: +4/-0
    • View Profile
Re: Maximum Length of custom field
« Reply #8 on: May 06, 2020, 03:35:16 AM »
THank you for your reply!

 

Powered by SMFPacks Social Login Mod