You are viewing limited content. For full access, please sign in.

Question

Question

Form Character Limit

asked on April 18, 2019

I am trying to set a specific numeric character limit in a form.  Instead of a maximum number of digits I want it to only be that specific number of digits.  For example if the account number is 5 digits I want the user to be able to only have 5 digits as a max but notified if there is less than 5.

0 0

Answer

SELECTED ANSWER
replied on April 18, 2019 Show version history

Use a RegEx, such as "\d{5}" (for numeric only) or :

You'll probably also want to add a custom error message, since the default doesn't tell the user much.

0 0
replied on April 18, 2019

This worked.  Thank you.

0 0

Replies

replied on April 18, 2019

Using a regular expression \d{1,5} will force it to be a number and between one and 5 characters.  You could write some JavaScript to provide a message if it is less than 5 digits.  A second alternative would be using \d{5} and putting a note either above or below the text to use leading 0s if less than 5 characters.

0 0
replied on April 18, 2019

Maybe the regular expression ".{5}" will not force to be number or letter but will force the 5 digits. Seems to work here.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.