# Is it possible to detect if a field is a text string vs numbers? (Data Validation for forms)

**URL:** <https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407>\
**Category:** Ask for Help\
**Created:** [May 26, 2022, 5:29pm UTC](https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407 "2022-05-26T17:29:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Majestic\_Intern](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/majestic_intern/32/36814_2.png) [@Majestic\_Intern](https://community.glideapps.com/u/Majestic_Intern)\
**Post date:** [May 26, 2022, 5:29pm UTC](https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407/1 "2022-05-26T17:29:46Z")

</div>

TL:DR Is there anyway to check if a string/field contains letters vs just numbers?

Hello everyone. I am working on an app that includes forms for contact information. These include fields like Phone Number, street number, and Zip Code which should only allow numbers, not letters. I used the number entry field which blocks users from entering letter characters on my laptop and I believe on android. But when testing the app on IOS, users can input letters. The good part is that they’re not allowed to submit the form with letters in those fields. The bad part is that it does not give them feedback or indication as to why they can not submit. So I was wondering if there was a way to check if the field contained letters and display a red rich text warning message when letters are present.

PS I tried setting the minimum value to 0 and the maximum to some arbitrary number, but it would not display an error message when text is entered

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [May 26, 2022, 5:53pm UTC](https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407/2 "2022-05-26T17:53:29Z")

</div>

Hola

What you need is a kind of validation based on RegEx (Regular Expression).

Take a look at this [RegEx challenge (or just seems that way)](https://community.glideapps.com/t/regex-challenge-or-just-seems-that-way/36138)

Saludos!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 26, 2022, 11:52pm UTC](https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407/3 "2022-05-26T23:52:02Z")

</div>

> [@Majestic\_Intern](#):
>
> I used the number entry field which blocks users from entering letter characters on my laptop

I believe you will have a problem when the ZIP starts with 0, what I would do is find an API to validate the ZIP instead, and use a text entry.

---

<div class="post-metadata">

**Author:** ![Majestic\_Intern](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/majestic_intern/32/36814_2.png) [@Majestic\_Intern](https://community.glideapps.com/u/Majestic_Intern)\
**Post date:** [May 31, 2022, 4:25pm UTC](https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407/5 "2022-05-31T16:25:08Z")

</div>

I ended up using the comment you posted on the RegEx thread of using ^ [0-9]+$ as the regular expression (although I have no idea what it actually means), and combining with custom forms using text entry fields and requiring that the regex is valid to submit. Are there any holes in that plan?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 31, 2022, 11:25pm UTC](https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407/6 "2022-05-31T23:25:22Z")

</div>

That regex will match the input from start (^) to end ($), matching one or more (+) digits [0-9]. The line must contain only digits in order to match ^ and $ on either end of the [0-9]+.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/5/35d75815dec5f9c0be7199868109a42aec85ae0e.png)

> **[RegExr: Learn, Build, & Test RegEx](https://regexr.com/3cr6f)**
>
> RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).

Here’s a regex translation tool whenever you need it. I think that plan is good enough.

---

<div class="post-metadata">

**Author:** ![Majestic\_Intern](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/majestic_intern/32/36814_2.png) [@Majestic\_Intern](https://community.glideapps.com/u/Majestic_Intern)\
**Post date:** [June 5, 2022, 2:37pm UTC](https://community.glideapps.com/t/is-it-possible-to-detect-if-a-field-is-a-text-string-vs-numbers-data-validation-for-forms/42407/7 "2022-06-05T14:37:58Z")

</div>

Thank You, I appreciate the support!
