Set minimum length for a text field on form?

Kelly_Sheetz
Level 2

Is there a way to natively set the minimum character limit for a text or number field in a form? I want to set a field to exactly 12 characters and have an error message appear if a lead enters anything less than 12 characters. If not, is there a javascript that anyone has used to accomplish this?

Thanks in advance!

Tags (1)
11 REPLIES 11
Kelly_Sheetz
Level 2

Since I am looking for a minimum and maximum of 12 numeric values, I used 999999999999 (12). When I test a live form, I am still able to submit the form with less than 12 numbers.

SanfordWhiteman
Level 10 - Community Moderator

Post a link to that form.

Kelly_Sheetz
Level 2

Here you go: AWS Activate

SanfordWhiteman
Level 10 - Community Moderator

There's no mask on the AWS Account ID field now.

Kelly_Sheetz
Level 2

When I go into the form it shows that there is mask input enabled:

Screen Shot 2017-09-08 at 1.32.43 PM.png

SanfordWhiteman
Level 10 - Community Moderator

Check the form and you'll see it isn't active. Maybe you didn't reapprove the LP.

SanfordWhiteman
Level 10 - Community Moderator

If you move the Q to Products​ I'll answer there (should be a Move button at the right).

Kelly_Sheetz
Level 2

Moved

SanfordWhiteman
Level 10 - Community Moderator

If you set the field to Text and use the Mask Input option (at the lower right in Form Editor), you can set the the pattern to

     ************

which is exactly 12 alphanumeric characters.

Nicholas_Manojl
Level 9

But.. if you want to do a minimum of 12 alphanumeric with some more.. you're out of luck. What are your thoughts on that Sanford?

SanfordWhiteman
Level 10 - Community Moderator

Enhance the special characters:

   MktoForms2.$.mask.definitions["_"] = "[A-Za-z0-9]?";

Then use this mask:

     ************_____

Where the underscores build out to the maximum length.