Limit phone fields to number of digits?

We’re looking to create three fields for phone number; area code, first 3, last 4, and use as horizontal fields. This is for a specific marketing automation/CRM use case. Is it possible to limit the number of digits allowed for each via custom code and also allow only digits and no special characters if we’re using generic validation?

Hey @Erik1,

You can do it but I would strongly advise against it from a UX perspective. Using 3 separate fields for a phone number creates a huge pain for the user, especially on mobile phones, where they have to tap 3 times to switch between the 3.

Also, you would break most auto-fill functions.

I would advice on using a single field, limit the number of digits and disallow special characters. After that use JS to split the result and write it to hidden fields.
(Alternatively, you can do it server-side before pushing the data to your end destination/CRM)


Ty @Hristian! Are there pre-built scripts you’re aware of that I can use in Unbounce that limit the number of digits, disallow special characters, split the result, and write to a hidden field, either somewhere in this community or on github? What are your thoughts on the Zapier solution @Finge outlines in this post?

If you have a Zapier account, I would go with it as it’s the easier solution to your particular use case.

Most of the things you want to do have scripts for workarounds but it can get pretty messy, pretty quickly with so many scripts being applied to the form.

Ty @Hristian! Do you know if it’s possible to do the concatenation of a field, partial of another, and add a word using Zapier before sending the value of the hidden field to Marketo? To find pre-built scripts, do you suggest just a simple google search or would you also search both here and on github directly as well?

If you are using Zapier, it won’t be a hidden field anymore.

The data would go from Unbounce > Zapier > Marketo.

You would use a hidden field if your pushing data from Unbounce > Marketo.

The partial field should be possible in theory. You might have to play around with Zapier a bit to get it working.

In another post, I linked to the master list of all scripts for Unbounce. I would start my search there. Google and Github searches are only helpful if you can edit/write your own scripts.