cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

auto format a text imput as time format

Hi guys:

 

Good day, I am looking to auto format a text imput label where when the user write an hour it change auto:

 

User write --> 1910
Auto format --> 19:10

 

as you can see I want to avoid to the user write the colon.

 

Is any way to do that?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: auto format a text imput as time format

Hi @felipito1 ,

This will work after the user presses Enter after 4 characters.

Put this on the OnChange of the Text control (call the Variable whatever you like)

If(
   Len(YourTextBoxName.Text) > 3,
   UpdateContext(
        {
            vColon: Left(
                TextInput1.Text,
                2
            ) & ":" & Right(
                TextInput1.Text,
                2
            )
        }
    );
    Reset(YourTextBoxName)
)

Make the Default of the Text box

vColon

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

5 REPLIES 5
Highlighted
Community Champion
Community Champion

Re: auto format a text imput as time format

Hi @felipito1 ,

This will work after the user presses Enter after 4 characters.

Put this on the OnChange of the Text control (call the Variable whatever you like)

If(
   Len(YourTextBoxName.Text) > 3,
   UpdateContext(
        {
            vColon: Left(
                TextInput1.Text,
                2
            ) & ":" & Right(
                TextInput1.Text,
                2
            )
        }
    );
    Reset(YourTextBoxName)
)

Make the Default of the Text box

vColon

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Highlighted
Community Support
Community Support

Re: auto format a text imput as time format

Hi @felipito1 ,

Do you want the Text Input value to be formatted as time automatically after you enter 4 number value?

 

Based on the needs that you mentioned, I think the Timer control could achieve your needs. Please consider add a Timer control in your app screen. Set the Duration property to following:

1000

set the AutoStart and Repeat property to following:

true

set the OnTimerEnd property to following:

If(
   Len(TextInput1.Text) = 4,   // TextIput1 represents the Text Input box where enter your time value
   Set(
       FormattedResult,
       Left(TextInput1.Text, 2) & ":" & Right(TextInput1.Text, 2)
   )
)

Set the Visible property of the Timer control to false.

 

Set the Default property of the TextInput1 to following:

FormattedResult

Please check the following GIF screenshot for more details:

Test1.gif

Note: The OnChange property of the Text Input could be fired only when the focus is move away from that Text Input box

 

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.
Highlighted
Community Champion
Community Champion

Re: auto format a text imput as time format

Thank You @v-xida-msft for the alternative.

@felipito1 you might try mine as well if you want something less complex

Highlighted
Community Champion
Community Champion

Re: auto format a text imput as time format

Hi @felipito1 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Helper II
Helper II

Re: auto format a text imput as time format

Hi @WarrenBelz  

Sorry my late reply, I have use that code on the "On change" property and it works really great!

 

Thank you! 

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

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

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (373)