cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rsparks
Level: Powered On

Forcing specific formatting in an input field

I have an input field that needs to take a costing string, depending on an earlier quesion the format will either be 12-123-123-1234-12345 OR 12345-123-1234-12-12345.

 

I've seen it in webforms before, not sure it's doable in powerapps. But for ease of filling out the form I'd like the input field to have the dashes pre-set, so that as someone is typing out they can see which section in the string they're filling out. 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Forcing specific formatting in an input field

Hi @rsparks ,

Do you want to have the dashes pre-set within the Text Input box within a canvas app?

Do you want to type a format string like 12-123-123-1234-12345 OR 12345-123-1234-12-12345 within a Text Input box?

 

Based on the needs that you mentioned, I afraid there is no way to achieve your needs in PowerApps currently. As an alternative solution, you could consider detect if the typed a text matches the specific format, if not, force the user re-type again.

 

I have made a test on my side, please take a try with the following workaround:1.JPG

Set the OnChange property of the Text Input box (TextInput1) to following:

 

If(
IsMatch(TextInput1.Text, "\d{2}\-\d{3}\-\d{3}\-\d{4}\-\d{5}") || IsMatch(TextInput1.Text, "\d{5}\-\d{3}\-\d{4}\-\d{2}\-\d{5}"),
true ,
Notify("The string format you typed is not valid, the correct format shoule be 12-123-123-1234-12345 or 12345-123-1234-12-12345",NotificationType.Error);Reset(TextInput1)
)

Please check the following GIF screenshot for more details:Test.gif

Note: You should type xx-xxx-xxx-xxxx-xxxxx string value or xxxxx-xxx-xxxx-xx-xxxxx string value within the Text Input box. The hyphen (-) should not be missed when you type the string value.

More details about the IsMatch function, please check the following article:

IsMatch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
Super User
Super User

Re: Forcing specific formatting in an input field

Hi @rsparks 

 

Currently PowerApps doesnot support auto-formatting of the text input control. You can choose either of the two formats: Text and Number.
 
As a workaround, you can place an error label on the screen which gets displayed when incorrect format string is added.
 
You can set the visibility of label as:
If(!IsMatch(TextInput1.Text,"^[0-9-]*$") && !IsBlank(TextInput2.Text),true,false)
Or if you have a specific format i.e. - will appear at so and so index, then you can write the expression as:
If(IsMatch(TextInput1.Text, Digit & Digit & Digit & Digit & Dash & Digit), false,true)
Here TextInput1 is the control name. 
 
Hope this helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Community Support Team
Community Support Team

Re: Forcing specific formatting in an input field

Hi @rsparks ,

Do you want to have the dashes pre-set within the Text Input box within a canvas app?

Do you want to type a format string like 12-123-123-1234-12345 OR 12345-123-1234-12-12345 within a Text Input box?

 

Based on the needs that you mentioned, I afraid there is no way to achieve your needs in PowerApps currently. As an alternative solution, you could consider detect if the typed a text matches the specific format, if not, force the user re-type again.

 

I have made a test on my side, please take a try with the following workaround:1.JPG

Set the OnChange property of the Text Input box (TextInput1) to following:

 

If(
IsMatch(TextInput1.Text, "\d{2}\-\d{3}\-\d{3}\-\d{4}\-\d{5}") || IsMatch(TextInput1.Text, "\d{5}\-\d{3}\-\d{4}\-\d{2}\-\d{5}"),
true ,
Notify("The string format you typed is not valid, the correct format shoule be 12-123-123-1234-12345 or 12345-123-1234-12-12345",NotificationType.Error);Reset(TextInput1)
)

Please check the following GIF screenshot for more details:Test.gif

Note: You should type xx-xxx-xxx-xxxx-xxxxx string value or xxxxx-xxx-xxxx-xx-xxxxx string value within the Text Input box. The hyphen (-) should not be missed when you type the string value.

More details about the IsMatch function, please check the following article:

IsMatch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 142 members 3,851 guests
Please welcome our newest community members: