web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Formatting phone numbe...
Power Apps
Answered

Formatting phone number to automatically

(0) ShareShare
ReportReport
Posted on by 19

Hello,

 

I have a field phone number, I need to format to the standard automatically and shows error message when user enters incorrect phone number standard. I have tries some of solutions posted on the community but it did't work.

Thank you

Categories:
I have the same question (0)
  • Anchov Profile Picture
    1,986 on at

    Could you please share the specific formulas you've tried and highlight the issues you're encountering with them? Additionally, let me know the format of the phone number you'd like to see, considering there are several "standards". If you have screenshots, that would be immensely helpful in providing more targeted assistance.

  • viny9889 Profile Picture
    19 on at

    1. restrict to 10 digit

    2. default to this format (xxx-xxx-xxxx)

    3. shows error message

  • Anchov Profile Picture
    1,986 on at

    Here is one solution:

    Anchov_0-1705076723301.png

    Formula used on Error Label visible property:

    !IsMatch(TextInput1.Text, "^\d{3}-\d{3}-\d{4}$")

    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    Cheers!
    Rick Hurt

  • viny9889 Profile Picture
    19 on at

    can u provide the steps clearly

  • Anchov Profile Picture
    1,986 on at

    This is a very simple set-up to show the concept only.  You can integrate this concept into your own app however you see fit.

    1. Add a Text Input control on a page (named TextInput1)

    2. Add a label control on your page

    3. On the label text property add your error message "Input must be in the format xxx-xxx-xxxx"

    4. On the label Visible property, add the formula:

    !IsMatch(TextInput1.Text, "^\d{3}-\d{3}-\d{4}$")

    This formula is evaluating the inputted text is in the desired format you specified (only digits, in the xxx-xxx-xxxx format). It does this using whats called a regex expression. Regex allows you to specify a alphanumeric pattern you want the user adhere to. The visible property expects the evaluation of the formula to evaluate to either true or false. In this case, if the pattern matches, we want the error message to be hidden visible, so it evaluates to false (thus the !)
    5. Play your app, when a user enter any value in the Text input control that is not in the format of xxx-xxx-xxxx, it will display the error label text, otherwise the label is not visible.

  • viny9889 Profile Picture
    19 on at

    1. the label is visible even before entering any number on the text input

    2. is there a formula to auto correct the phone number?

  • Verified answer
    Anchov Profile Picture
    1,986 on at

    1. the label is visible even before entering any number on the text input
    - Yes, again its simplified concept to show do do your minimum requirement, you will need to alter it to meet your needs. For example if you don't to see the message if its blank alter the expression as follows:

    !IsMatch(TextInput1.Text, "^\d{3}-\d{3}-\d{4}$") And !IsBlank(TextInput1.Text)

    2. is there a formula to auto correct the phone number?
    Not a simple solution, but Mathew Devaney has a good write up on how to accomplish this:
    https://www.matthewdevaney.com/power-apps-phone-number-formatting-in-a-form-input-mask/

     

  • viny9889 Profile Picture
    19 on at

    I have tried the post from Mathew, but did't work

  • viny9889 Profile Picture
    19 on at

    btw, just retired Mathew's post and it worked, Thanks for your time and support!

  • Anchov Profile Picture
    1,986 on at

    sure, can you please mark the post with Mathew's link as "Accept as Solution" so others can find it quickly?  Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 136 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard