Phone Number Validation in Forms | Community
Skip to main content
March 20, 2014
Question

Phone Number Validation in Forms

  • March 20, 2014
  • 5 replies
  • 7958 views
Hi all, 

I noticed some leads coming in with invalid phone numbers, only 8 digits long. 

Just tested this and confirmed my form will accept 12345678 as a phone number, although it won't accept 1234567. 

I understood that the default "Phone" field (which has a type of "Phone") should ensure proper validation, but it seems to not be the case. 

How can I make this field require at least 10 digits? 

I'm not looking for super-fancy formatting or anything, just ensure it has a minimum of 10 digits so the number is ostensibly valid. 

Thanks!
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

Level 10
March 20, 2014
Hi Justin,

You can use Mask Input for this purpose. Change the field type to text and enable Mask input. Use "9" to mean any number, "a "to mean any letter and * to be either one. In your case, for the field to require 10 digits, you can use 9999999999.



For more, refer this help article to Apply Input Masking to a field in a form.

Hope this helps!
Josh_Hill13
Level 10
March 20, 2014
Just be careful here because international #s won't validate unless you have that * on either end.
March 20, 2014
Hi guys, 

Thanks for the feedback -- didn't know about the Mask Input functionality. 

Problem is, when I try to do this I get an error message: 

Only custom fields can change type
 

Is it really possible that there is no way to validate the default Phone field that is in SFDC? It would seem nuts to have to create a new custom phone field and re-organize my entire CRM instance to get a properly validated phone field but that would seem the only way (hope I'm wrong!)

Thoughts?

Thanks again. 
March 20, 2014
Ah I just checked the article you posted and I think I understand now. 

You are talking about changing the field type at the form level -- I thought you meant to change the type in the field administration section. My bad.  

So next problem is this is a 1.0 form (not 2.0). Is the masking functionality only available in Forms 2.0? I can't seem to find it in the legacy forms editor. 

I haven't transitioned these to Forms 2.0 yet since they have some limitations with my CMS (wordpress). 
August 20, 2014
So will masking only work with US to ensure US based phone #s?

Is there some way to do a conditional field where a (xxx) xxx-xxxx shows up if United States is chosen as a country? Otherwise, show the normal #format (or better yet, show an the phone format based on country).
Angela_Ruggeri1
Level 2
March 31, 2016

Has anyone found this out?

Casey_Grimes2
Level 10
March 31, 2016

Hi Angela,

This would be pretty easy to do with a little bit of JS knowledge (just combine a listener for whatever country's chosen and something a la jQuery Mask Plugin.) However, I don't think there's anything that does it out of the box, no.