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