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

How to standardize text in a format?

Hello!!!
I have a text entry in my application and I wanted the user to type a document in the text box to be in a standard example:
12345678900 = 123.456.789-00

I have already used the text and validate function and was not successful.
Can someone help me?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to standardize text in a format?

Hi @Leandrosg ,

Could you please share a bit more about your scenario?

Do you want to format the entered value 12345678900 as 123.456.789-00?

 

I assume that you would enter 11 digit value within the Text Box, according to the needs that you mentioned, I think the OnChange property of the Text Input Box could achieve your needs.

I have made a test on my side, please try the following workaround:

Set the OnChange property of the Text Input Box to following:

If(
   Len(TextInput1.Text) >= 11,
   Set(
        FormattedValue,
        Left(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "." &
        Right(
              Left(
                   Left(TextInput1.Text, Len(TextInput1.Text)-2),
                   6
              ),
              3
        ) & "." &
        Right(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "-" & Right(TextInput1.Text, 2)
   )
)

Set the Default property of the Text Input Box to following:

FormattedValue

Please check the following GIF screenshot for more details:

Test.gif

Note: The OnChange property of the Text Input Box would be fired only when the focus is moved away from the Text Input Box

 

If you want the entered value within the Text Input box to be formatted automatically, I think the Timer control could achieve your needs. You could consider add a Timer control in your app, set the Duration property to following:

1000

set the AutoStart and Repeat property of the Timer control to following:

true

set the OnTimerEnd property to following:

If(
   Len(TextInput1.Text) >= 11,
   Set(
        FormattedValue,
        Left(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "." &
        Right(
              Left(
                   Left(TextInput1.Text, Len(TextInput1.Text)-2),
                   6
              ),
              3
        ) & "." &
        Right(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "-" & Right(TextInput1.Text, 2)
   )
)

Set the Default property of the Text Input Box to following:

FormattedValue

 

Please consider take a try with above solution, then check if the issue is solved.

 

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.

View solution in original post

2 REPLIES 2
Highlighted
Super User
Super User

Re: How to standardize text in a format?

@Leandrosg 

Use 4 separate text boxes.  Put a label in the middle of each one with the desired syntax.  Change the MaxLength of each label to your requirement.  The user can press tab to skip to the next text box.

 

Then join them together to submit the result:

 

Text1.Text&”.”&Text2.Text&”.”Text3.Text&”-“&Tdxt4.Text


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

Highlighted
Community Support
Community Support

Re: How to standardize text in a format?

Hi @Leandrosg ,

Could you please share a bit more about your scenario?

Do you want to format the entered value 12345678900 as 123.456.789-00?

 

I assume that you would enter 11 digit value within the Text Box, according to the needs that you mentioned, I think the OnChange property of the Text Input Box could achieve your needs.

I have made a test on my side, please try the following workaround:

Set the OnChange property of the Text Input Box to following:

If(
   Len(TextInput1.Text) >= 11,
   Set(
        FormattedValue,
        Left(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "." &
        Right(
              Left(
                   Left(TextInput1.Text, Len(TextInput1.Text)-2),
                   6
              ),
              3
        ) & "." &
        Right(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "-" & Right(TextInput1.Text, 2)
   )
)

Set the Default property of the Text Input Box to following:

FormattedValue

Please check the following GIF screenshot for more details:

Test.gif

Note: The OnChange property of the Text Input Box would be fired only when the focus is moved away from the Text Input Box

 

If you want the entered value within the Text Input box to be formatted automatically, I think the Timer control could achieve your needs. You could consider add a Timer control in your app, set the Duration property to following:

1000

set the AutoStart and Repeat property of the Timer control to following:

true

set the OnTimerEnd property to following:

If(
   Len(TextInput1.Text) >= 11,
   Set(
        FormattedValue,
        Left(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "." &
        Right(
              Left(
                   Left(TextInput1.Text, Len(TextInput1.Text)-2),
                   6
              ),
              3
        ) & "." &
        Right(
              Left(TextInput1.Text, Len(TextInput1.Text)-2),
              3
        ) & "-" & Right(TextInput1.Text, 2)
   )
)

Set the Default property of the Text Input Box to following:

FormattedValue

 

Please consider take a try with above solution, then check if the issue is solved.

 

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.

View solution in original post

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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