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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Trying to convert user...
Power Apps
Answered

Trying to convert user inputted numbers into phone number format in PowerApps form

(0) ShareShare
ReportReport
Posted on by 94

Hello everyone,

 

Just as a disclaimer, I have been working on this issue for the past few hours, and have done extensive research and basically read through every bit of information I could find, but I am still having trouble.

 

I have a PowerApps form that is connected to a SharePoint Online list. We have a phone number field, and I am trying to basically transform the numbers people input into the US xxx-xxx-xxxx format. I've tried using a bunch of different TextFormat.Number related modifications, but to no avail. I've also tried converting the input method/type to Text, and using TextFormat.Text=Text(Value(DataCardValue6),"[$-en-US](000)-000-0000").

 

Anyways, I'll be incredibly grateful for any help that anyone can provide. Thank you so much in advance! 

 

Edit: I've also tried TextFormat.Text=Text(Value(DataCardValue6.Text),"[$-en-US](000)-000-0000"). And a lot of variations on this. I keep getting exceptions, so I obviously don't know what I'm doing. 🙂

Categories:
I have the same question (0)
  • Meneghino Profile Picture
    6,949 on at

    Hi @nealhicks1

     

    Which of the following are you tring to do?

     

    1) Ensure that the input is in the format (xxx)-xxx-xxxx and only accept such input

    OR

    2) Accept any reasonable input (like 1234567890) and convert it to (123)-456-7890 when updating the SP list

     

    The first task is obviously much easier. All it requires is to have your text input in text mode and use the IsMatch function in a simple way.  For example to enable the save button (via the DisplayMode property) only if IsMatch is positive.

     

    The second task requires to define which patterns are acceptable and have a correspondingly complex IsMatch condition or series of conditions to enable the save button.  Then you will need a parsing function using string functions depending on the pattern of the input.

     

    Hope this helps

  • nealhicks1 Profile Picture
    94 on at

    Hello @Meneghino,

     

    Thanks for the response! Smiley Happy

     

    I'm not strong with the coding, so I would vote on whichever option would require less coding to get working. 🙂

     

    If I were wanting to go with option 1, how do I go about actually implementing the necessary IsMatch condition?

     

    Also, I'm having a problem where any inputted numbers are basically turned into.. well, say that 1234567890 is inputted, then it will turn that into 1,234,567,890, displaying commas and everything. So I need to somehow ensure that the numbers are displayed in the 123-456-7890 format.

     

    I really appreciate your help with this!

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    The phone number field will need to be a text field. The IsMatch function would look like this:

     

    IsMatch(PhoneNumberField.Text, LeftParen & Digit & Digit & Digit & RightParen & Hyphen & Digit & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit)

    It will return true if it matches the format (###)-###-#### otherwise it returns false.

  • nealhicks1 Profile Picture
    94 on at

    Apologies for my ignorance, but where exactly do I input that string? I've been looking all through the Properties and Advanced tabs, but I can't seem to find the right place for that. I am very new at PowerApps, so I apologize for the trouble!

     

    Also, @Jeff_Thorpe, thanks for helping me out with both my threads. 🙂

  • Verified answer
    Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    You can use it with an If condition in the OnSelect property of Submit button/icon. If the format is true it process SubmitForm otherwise it returns false.

     

    If(IsMatch(PhoneNumberField.Text, LeftParen & Digit & Digit & Digit & RightParen & Hyphen & Digit & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit), SubmitForm(EditForm), false)

    This isn't to user friendly because the user doesn't know why the form wasn't saved. To make this more user friendly you would need to add a label to the form to display the error message. Then you would need to replace false in the If condition with some code that would make the error message label visible.

     

     

  • Verified answer
    Meneghino Profile Picture
    6,949 on at

    To enhance what @Jeff_Thorpe is suggesting, I would say that you could place the IsMatch expression in the DsiplayMode property of the submit button, so that it is disabled unless the input text is in the format you want.  This way the button is not pushable.

    Something like this for the DisplayMode property:

    If(IsMatch(PhoneNumberField.Text, LeftParen & Digit & Digit & Digit & RightParen & Hyphen & Digit & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit), DisplayMode.Edit, DisplayMode.Disabled)
  • nealhicks1 Profile Picture
    94 on at

    Thanks for all the suggestions!

     

    So when you say that I could place the IsMatch expression in the DisplayMode property of the submit button, from where do I go about doing that? In the Advanced tab? I am trying to find the right place to insert that IsMatch code, but I am not sure where I should do that.

     

    Sorry for the likely extreme level of newbie-ness!

     

     

  • Verified answer
    Meneghino Profile Picture
    6,949 on at

    1.JPG

  • nealhicks1 Profile Picture
    94 on at

    Thank you very much! I think I'm good with this, now.

     

    I appreciate everyone's help!

  • sandersen220 Profile Picture
    4 on at

    My phone field in SharePoint is set to text entry. Here is the Text display Value in PowerApps:

     

    "("&Mid(DataCardValue39.Text,1,1)&Mid(DataCardValue39.Text,2,1)&Mid(DataCardValue39.Text,3,1)&") "&Mid(DataCardValue39.Text,4,1)&Mid(DataCardValue39.Text,5,1)&Mid(DataCardValue39.Text,6,1)&"-"&Mid(DataCardValue39.Text,7,1)&Mid(DataCardValue39.Text,8,1)&Mid(DataCardValue39.Text,9,1)&Mid(DataCardValue39.Text,10,1)&" (Cell)"

     

    This does not control the input mask for the phone field on the form- I am repurposing it on a review/confirmation screen prior to the user submitting the form. Hope this helps in some way.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard