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 / Format a number to (##...
Power Apps
Answered

Format a number to (###) ###-####

(0) ShareShare
ReportReport
Posted on by 185

I am trying to convert a 10 digit entered number to a telephone number. For example if 9291234321 is enter, I want it to be converted to (929) 123-4321. How can I achieve this?

 

knishal_1-1659466301300.png

 

 

Categories:
  • tomsaudrins Profile Picture
    74 on at

    This can be achieved by creating an input mask.

    You can use this number format in the "Default" property: (###) ###-####

     

    You can read more about this here: https://www.matthewdevaney.com/power-apps-phone-number-formatting-in-a-form-input-mask/

  • Sumaira_Noor Profile Picture
    18 on at

    You can also try the below code @knishal 

    Text(Your Input, "(###) ###-####", "en-GB")

  • knishal Profile Picture
    185 on at

    @Sumaira_Noor I got the follow error when I try to add it in the Default 

    knishal_0-1659467085926.png

     

  • Sumaira_Noor Profile Picture
    18 on at

    Did you try setting only "(###) ###-####" @knishal ?

  • Sumaira_Noor Profile Picture
    18 on at
  • Sumaira_Noor Profile Picture
    18 on at

    @knishal 

     

    If(
    Not(IsMatch(TextInput1.Text, "\d{3}-\d{3}-\d{4}")) && !IsBlank(TextInput1.Text),
    RGBA(255, 0, 0, 1), /* <-- If doesnt match, border color turn into red */
    RGBA(0, 18, 107, 1)
    )

     

    The above should work when you put on border property

  • knishal Profile Picture
    185 on at

    I give it a try and got the error below

    knishal_0-1659529300376.png

     

    This is my phone number field and its a single line text 

    knishal_1-1659529350541.png

     

    @Sumaira_Noor @tomsaudrins 

     

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @knishal ,

     

    You could try:

     

    Set the TextInput's OnChange property to:

    If(
     !IsMatch(Self.Text,"\(\d*\) \d{3}-\d{4}") ||IsEmpty(Self.Text),
     If(
     IsMatch(Self.Text,"\d{10}"),
     Set(TheValue,"("&Left(Self.Text,3)&") "& Mid(Self.Text,4,3)&"-"&Right(Self.Text,4));Reset(Self),
     Notify("Wrong Format!It should be 9291234321 or (929) 123-4321");Set(TheValue,"");Reset(Self)
     )
    )
    

     

    Set the  TextInput's Default property to:

    TheValue

     

    Best Regards,

    Bof

  • knishal Profile Picture
    185 on at

    Works, thank you so much

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard