Set minimum length for a text field on form?

Kelly_Sheetz
Level 2

Set minimum length for a text field on form?

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
SanfordWhiteman
Level 10 - Community Moderator

Re: Set minimum length for a text field on form?

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

Kelly_Sheetz
Level 2

Re: Set minimum length for a text field on form?

Moved

SanfordWhiteman
Level 10 - Community Moderator

Re: Set minimum length for a text field on form?

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

Re: Set minimum length for a text field on form?

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

Re: Set minimum length for a text field on form?

Enhance the special characters:

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

Then use this mask:

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

Where the underscores build out to the maximum length.

Kelly_Sheetz
Level 2

Re: Set minimum length for a text field on form?

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

Re: Set minimum length for a text field on form?

Post a link to that form.

Kelly_Sheetz
Level 2

Re: Set minimum length for a text field on form?

Here you go: AWS Activate

SanfordWhiteman
Level 10 - Community Moderator

Re: Set minimum length for a text field on form?

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