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 / Auto (Slash) add in in...
Power Apps
Answered

Auto (Slash) add in input field

(0) ShareShare
ReportReport
Posted on by 58

Hi All,

I have been trying to create a user form. I have a field named "Valid to" were user will be typing date in (mm/dd/yyy) format and I have some other conditions so I cant use Date picker . My query is when user typing date I need to auto populate slash(/) between the mm/dd/yyy is it possible to add slash between intervals so user don't have to add slash manually.

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    What about letting User select a DatePicker and the results or what has been selected Automatically populate the Textbox?

     

    In the Default of the Textbox;

    DatePicker1.SelectedDate

    Format the DatePicker to "mm/dd/yyyy"

     

    If that's not ok try validating the Textbox using the Fill color;

    If(IsMatch( "11/11/1111", "\d{2}-\d{2}-\d{4}" ),White,Red)

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    I like where @eka24 is going with the IsMatch Regex, and I think we can extend that to actually insert the slashes when the format matches one of two correct formats.

     

    So keep the Text colour setting @eka24 suggested, this will notify the user when the format they've entered is incorrect, but only if it matches ##-##-####, so we can extend that to include ######## and ##/##/#### as well:

    If(
     IsMatch( Self.Text, "\d{2}-\d{2}-\d{4}" )
     ||
     IsMatch( Self.Text, "\d{2}\d{2}\d{4}"
     ||
     IsMatch( Self.Text, "\d{2}\/\d{2}\/\d{4}" )
     ,White,Red
    )

     

    Then in your control's Default, set it to DateValidated

    (a variable we will shortly set via the OnChange)

     

    in your control's OnChange, have it do the following:

    If(
     IsMatch(Self.Text), "\d{2}-\d{2}-\d{4}",
     Set(DateValidated,
     Left(Self.Text,2) & "/"
     & Mid(Self.Text,4,2) & "/"
     & Mid(Self.Text,7,4)
     ),
     IsMatch(Self.Text), "\d{2}\d{2}\d{4}",
     Set(DateValidated,
     Left(Self.Text,2) & "/"
     & Mid(Self.Text,3,2) & "/"
     & Mid(Self.Text,5,4)
     )
    )

     

    What the above does is adds in the text slashes to either 01032020 or to 01-03-2020 if it matches those patterns 🙂

     

    Hope this helps!

     

    Cheers,

    Sancho

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard