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.
Solved! Go to Solution.
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
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
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.
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
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
198 | |
70 | |
50 | |
46 | |
20 |
User | Count |
---|---|
253 | |
120 | |
84 | |
79 | |
69 |