cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sruvira
Frequent Visitor

Hardcode input mask values OR show mask on views

Hi all,

I've been searching everywhere, but I can't find anyone who is looking for the same thing as me. I know I can create an input mask, but then I want to do one of two things with it. Either:

 

  1. Save the resulting input with the input mask hardcoded in. For example, if my phone number mask is: (000) 000-0000, then I want to save the phone number with the parentheses and hyphen hardcoded into the entry. So the entry into my database would be (102) 421-8716, but the user only entered 1024218716.
  2. OR, I would be okay with keeping the input as the raw number if I could then display it with the input mask applied on views. So the entry in my database is simply 1024218716, but it has the format of (102) 421-8716 everywhere that the users see it on a View.

Any advice would be much appreciated! 

2 REPLIES 2
Pstork1
Dual Super User
Dual Super User

To the best of my knowledge none of the controls in Power Apps actually support an input mask.  You can use Regex to validate the input and show an error message if it doesn't match, but there isn't a formal property for applying an input mask.



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

Like @Pstork1 said there's no automatic change to a number that will display as they type.

 

If you have a number that is always in 8188887654 / 10 digit format with no separators you can display it properly using 

 

 

"("&Left(TextInput1.Text,3)&")"&Mid(TextInput1.Text,4,3)&"-"&Right(TextInput1.Text,4)

 

 

this works great until someone types theirs in formated properly at which point pulling it from data would look crazy like this ((81)8)8-9152

 

so what you do when submitting these to the database is remove any formatting like so 

 

Substitute(Substitute(Substitute(TextInput1.Text,"(",""),")",""),"-","")

 

now you can store the number as a basic 10 digit number in your database, not worry about people typing either or, and still display the version you want. Best of all worlds

 

When submitting that reformatted number i would also run a Len on it to ensure the user input the correct number of digits when typing their number, for safety. Like so

If(Len(Substitute(Substitute(Substitute(TextInput1.Text,"(",""),")",""),"-",""))=10,Substitute(Substitute(Substitute(TextInput1.Text,"(",""),")",""),"-",""),"Error")
_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,095)