web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Having a set character...
Power Apps
Unanswered

Having a set character in a text input

(0) ShareShare
ReportReport
Posted on by

Hi!

I want the user to add the date in a text input as YY/WW, and I therefor want a slash to be added automatically after the user has entered two values.

As now, my code looks like this in the text input's OnChange: 

If( Len(Datuminput.Text) = 2, Datuminput.Text = Datuminput.Text&Char(47) )

But it isn't working as I hoped it would... does anyone have any suggestions?

Thanks!

Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @Anonymous,

    Do you mean date format like 2023/week 15?

    Could you please tell me that how you define two values in the Datuminput? Two characters? How you convert two characters into YY/WW?

     

    Actually, in Power Apps, to convert date into YY, we used to use the "yy".

    If you just want to add a year to the TextInput where inputs weeknumber, I think you should set the OnChange property of the Datuminput as below:

    If(Len(Datuminput.Text) = 2,Set(DateFormat,Text(Today(),"yy")&Char(47)&Datuminput.Text))

    Then you need to apply this variable to the Default property of the Datuminput:

    DateFormat

     

    What's more, to trigger the variable in the OnChange property, you need to click anywhere outside of the Datuminput, so that the variable will be triggered.

     

  • Community Power Platform Member Profile Picture
    on at

    Well, I first defined DatumInput as a value and not a text, since I wanted the user to enter numbers. But I didn't get numbers to work with adding a character to the text, and therefor I changed the format to text.

    I haven't yet decided how to collect the data from the user's input, but the plan is that it'll be a total of four characters in the input, the first two for the year, and the last two for the number of the week, and with a slash in between them so that it's clear for the user what they're entering in the textbox!

    Did that make it more clear?

    Best regards

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @Anonymous,

    Do the end users input year value and week number value at the same time?

     

    If so, please add a timer and set a variable as below:

    vqiaqimsft_0-1687765605770.png

    Set the OnTimeStart property as:

    Set(varDate,If(Len(TextInput2.Text)=2,TextInput2.Text&Char(47),TextInput2.Text))
  • Community Power Platform Member Profile Picture
    on at

    Yes they will enter the values at the same time! It looks like this:

    hazzel_0-1687853729213.png

    I tried adding a timer, but I don't really see what purpose it has in this case?

    Best regards

  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @Anonymous,

    It will always refresh the variable in a duration without you trigger the OnChange property.

    Before, you need to click anywhere outside of the Datuminput when Datuminput has input change within, but with the Timer, this variable is generated in a short time without triggering the OnChange property.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard