# Phone number validation

**URL:** <https://community.glideapps.com/t/phone-number-validation/3064>\
**Category:** Ask for Help\
**Created:** [December 22, 2019, 10:25am UTC](https://community.glideapps.com/t/phone-number-validation/3064 "2019-12-22T10:25:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jake\_z](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jake\_z](https://community.glideapps.com/u/jake_z)\
**Post date:** [December 22, 2019, 10:25am UTC](https://community.glideapps.com/t/phone-number-validation/3064/1 "2019-12-22T10:25:18Z")

</div>

I have a form with a phone number text input field. It seems to allow users to type anything in, i.e. they can submit if they type “a” into the phone number field in the add form. Is it possible to require a valid 10 digit number and show the number pad instead of alphabetical keyboard?

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [June 24, 2020, 3:11pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/2 "2020-06-24T15:11:06Z")

</div>

The text fields are really useless for the time being and can’t even validate emails

---

<div class="post-metadata">

**Author:** ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)\
**Post date:** [June 25, 2020, 2:59am UTC](https://community.glideapps.com/t/phone-number-validation/3064/3 "2020-06-25T02:59:29Z")

</div>

@jake_z you could do the validation in google sheets and reject the submission.

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [July 25, 2020, 10:10pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/4 "2020-07-25T22:10:30Z")

</div>

Explain more

---

<div class="post-metadata">

**Author:** ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)\
**Post date:** [July 25, 2020, 10:27pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/5 "2020-07-25T22:27:01Z")

</div>

Hi @Yasin_Hassanien,

IT isn’t really an elegant solution but it is workable dependant on your requirements and if instantaneous feedback is something you can do without.

I will go find my previous post on this…

---

<div class="post-metadata">

**Author:** ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)\
**Post date:** [July 25, 2020, 10:28pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/6 "2020-07-25T22:28:20Z")

</div>

You can do the validation yourself if needed. I have addressed this question a few times and there is a way to workaround this issue.

The gist of it is, have the user enter all the information that requires validation into user fields (not in a form) and validate it. Once all values have been validated, a form button appears. Once the form is opened all the values previously entered are shown (no longer editable) for confirmation and then the user submits the form.

In this way you can validate the input prior to accepting the form entry. It’s not ideal but it is really only one extra click from the user… Not too much of a price to pay.

From a users perspective it also feels ok I think as it’s the confirmation page you have in many websites that make you click accept and if you don’t like what you chose, have to back out and change it.

The validation is done on sheets rather than glide as you can do any sort of validation in sheets. The tradeoff is speed. Since it’s going into and from sheets the validation will take 3-5s round trip possibly.

---

<div class="post-metadata">

**Author:** ![kiptoo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kiptoo/32/57036_2.png) [@kiptoo](https://community.glideapps.com/u/kiptoo)\
**Post date:** [April 22, 2023, 7:47am UTC](https://community.glideapps.com/t/phone-number-validation/3064/7 "2023-04-22T07:47:43Z")

</div>

Consider this other workaround: [Data entry mask on phone or email component? - #3 by kiptoo](https://community.glideapps.com/t/data-entry-mask-on-phone-or-email-component/6746/3)

---

<div class="post-metadata">

**Author:** ![Christopher\_Collins](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/christopher_collins/32/76926_2.png) [@Christopher\_Collins](https://community.glideapps.com/u/Christopher_Collins)\
**Post date:** [June 24, 2024, 11:18pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/8 "2024-06-24T23:18:49Z")

</div>

Hi jake\_z,

Now that Glide is integrated with [Zapier](https://zapier.com/), you can automate the checking, verification, and formatting of phone numbers. Here’s how you can set it up step-by-step:

1. **Create a New Zap in Zapier** :

2. **Set Glide as the Trigger App** :

3. **Add OpenAI API as an Action** :

4. **Add Numverify as Another Action** :

5. **Update the Record in Glide, Google Sheets, or Another CRM** :

6. **Test the Zap** :

7. **Turn on the Zap** :

By following these steps, you can automate the phone number verification and formatting process using Glide, OpenAI, Numverify, and your CRM of choice through Zapier.

Hope this helps

Christopher

---

<div class="post-metadata">

**Author:** ![w11](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/w11/32/36457_2.png) [@w11](https://community.glideapps.com/u/w11)\
**Post date:** [April 23, 2025, 11:00am UTC](https://community.glideapps.com/t/phone-number-validation/3064/9 "2025-04-23T11:00:05Z")

</div>

this maybe a day late and a dollar short. I don’t even know if it is allowed, but I use a javascript validation for phone numbers. I have the customer enter any numbers into a text field with minimum characters being 10. This is in America by the way, so that number includes area code. I then use a conversion column and display the output to what I want to see:

p1 = p1.toString(); // convert p1 to a string  
p1 = p1.replace(/\D+/g, ‘’); // remove all non-digit characters  
if (p1.length !== 10) {  
return(‘’);  
} else {  
return(‘(’ + p1.substring(0, 3) + ') ’ + p1.substring(3, 6) + ‘-’ + p1.substring(6));  
}

var phonePattern = /\d+/g;  
let phoneText= p1.match(phonePattern).join(‘’);

let len=phoneText.length;  
let string4=phoneText.slice(len-4,len);  
let string3=phoneText.slice(len-7,len-4);  
let string2=phoneText.slice(len-10,len-7);  
let string1=phoneText.slice(0,len-10);

return string1+ " (" + string2+ ") " +string3+ “-” + string4

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [April 23, 2025, 11:57am UTC](https://community.glideapps.com/t/phone-number-validation/3064/10 "2025-04-23T11:57:35Z")

</div>

Is that supposed to be two separate scripts?

---

<div class="post-metadata">

**Author:** ![w11](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/w11/32/36457_2.png) [@w11](https://community.glideapps.com/u/w11)\
**Post date:** [April 23, 2025, 12:47pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/11 "2025-04-23T12:47:49Z")

</div>

No it is in the experimental section I will send screenshots later today

---

<div class="post-metadata">

**Author:** ![w11](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/w11/32/36457_2.png) [@w11](https://community.glideapps.com/u/w11)\
**Post date:** [April 23, 2025, 12:49pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/12 "2025-04-23T12:49:52Z")

</div>

Just paste that into that code section on the experimental JavaScript section and then assign P1 in the drop down selection to be whatever field you’re inputting the numbers in. I then on my data showing side I pointed to that field and it creates my formatted phone number

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [April 23, 2025, 12:54pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/13 "2025-04-23T12:54:30Z")

</div>

Yeah, but it looks like two separate scripts. The second half of it will never run because of the returns that occur beforehand. The second half seems to be a slightly different version of the first half, but basically doing the same thing.

---

<div class="post-metadata">

**Author:** ![w11](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/w11/32/36457_2.png) [@w11](https://community.glideapps.com/u/w11)\
**Post date:** [April 23, 2025, 1:10pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/14 "2025-04-23T13:10:07Z")

</div>

I might have forgotten to cancel out one of them or combing out one of them. I was in a haste when I put it in email

---

<div class="post-metadata">

**Author:** ![w11](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/w11/32/36457_2.png) [@w11](https://community.glideapps.com/u/w11)\
**Post date:** [April 23, 2025, 1:19pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/15 "2025-04-23T13:19:13Z")

</div>

Okay I went and looked at what I posted and I realized what you’re talking about. Yeah you can just use the top half. I believe the second was me testing things.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [April 23, 2025, 1:19pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/16 "2025-04-23T13:19:54Z")

</div>

Looks like you may or may not have been trying to account for country code. Here’s a version that should format properly with and without country code included following the North American Numbering Plan.

```auto
function formatPhoneNumber(input) {
  // Remove all non-digit characters
  let digits = input.toString().replace(/\D+/g, '');

  // Must have at least 10 digits for a valid number
  if (digits.length < 10) {
    return '';
  }

  // Extract last 10 digits as local number
  let localNumber = digits.slice(-10);
  let countryCode = digits.length > 10 ? '+' + digits.slice(0, -10) : '';

  // Format local number
  let areaCode = localNumber.slice(0, 3);
  let centralOffice = localNumber.slice(3, 6);
  let lineNumber = localNumber.slice(6);

  return `${countryCode} (${areaCode}) ${centralOffice}-${lineNumber}`;
}

return formatPhoneNumber(p1);

```

---

<div class="post-metadata">

**Author:** ![w11](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/w11/32/36457_2.png) [@w11](https://community.glideapps.com/u/w11)\
**Post date:** [April 23, 2025, 1:21pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/17 "2025-04-23T13:21:21Z")

</div>

You sir are a blessing. I have been using those above for years. Thank you!!!

---

<div class="post-metadata">

**Author:** ![StuartPembery](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/stuartpembery/32/83235_2.png) [@StuartPembery](https://community.glideapps.com/u/StuartPembery)\
**Post date:** [April 23, 2025, 3:19pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/18 "2025-04-23T15:19:15Z")

</div>

Small point of detail but it’s very common for multinationals to have telephone numbers in the format +44 (0)7766 123456.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [April 23, 2025, 3:34pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/19 "2025-04-23T15:34:15Z")

</div>

Yep, I was just following the NANP format. Wasn’t meant to cover all international cases. Moreso, just modifying and clarifying what @w11 was sharing.

---

<div class="post-metadata">

**Author:** ![StuartPembery](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/stuartpembery/32/83235_2.png) [@StuartPembery](https://community.glideapps.com/u/StuartPembery)\
**Post date:** [April 23, 2025, 3:38pm UTC](https://community.glideapps.com/t/phone-number-validation/3064/20 "2025-04-23T15:38:53Z")

</div>

Understood 🙂

[Next page](https://community.glideapps.com/t/phone-number-validation/3064.md?page=2)
