Author Topic: Max characters text box  (Read 4154 times)

Offline Mike

  • Newbie
  • *
  • Posts: 16
  • Karma: +4/-0
    • View Profile
Max characters text box
« on: December 22, 2016, 11:24:37 AM »
Hi Guys

A couple of product which we offer on our site have an option to add engraving.

At the moment I have a textbox on the product page where the customer can enter the message that they want to have engraved.

Does anyone know of a way to limit the characters which can be entered - for example:
Max 20 characters with the 20 displayed and counting down as characters are entered - I'm sure you've seen the sort of thing I'm talking about.

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: Max characters text box
« Reply #1 on: December 23, 2016, 12:21:21 AM »
Hi. Every option in AbanteCart have Regular Expression Pattern and Error Message about invalid Value fields.

Try them for allow only 20 chars. For the counting while typing customization required... some simple javascript

Offline Mike

  • Newbie
  • *
  • Posts: 16
  • Karma: +4/-0
    • View Profile
Re: Max characters text box
« Reply #2 on: December 23, 2016, 03:15:01 AM »
Thank you.

I don't know Javascript but after a bit of googling and a couple of visits to Stack overflow I have managed to get something that works.

            /^.{,40}$/

It doesn't show a countdown box as the user types but it does limit the characters to a maximum of 40.

If anyone knows how to add a countdown box then please share :)

 

Powered by SMFPacks Social Login Mod