-1

Good day! I have created a new power app. In the application one of the text input field user will update date and time values Ex format : 29/12/2022 10:30 AM

Before saving the data I need to validate the format like (DD/MM/YYYY HH:MM AM/PM).

Could you please some one help if user entered the wrong format need through error message or highlight the field.

2 Answers2

0

This approach may not be the best UX. It could cause users to try multiple times until they get it right.

Why not use a datepicker with dropdowns for hours, minutes and seconds? You could then combine the inputs into a datetime value and format it as required using Text(). The necessity to validate formats is elimated.

mmikesy90
  • 783
  • 1
  • 4
  • 11
0

Try this code in OnChange property of the text box.

If
(!IsMatch(TextInput1.Text,"\d{2}/\d{2}/\d{4} (1[0-12][1-9]):[0-5][0-9] ([AaPp][Mm])"
),
Notify("Please enter DD/MM/YYYY 00:00 AM/PM Format", NotificationType.Error);Reset(TextInput1)
)

Output : If you enter correct format( 01/02/2023 11:00 AM) it wil move to next field otherwise displays a notification error.

Fedor
  • 17,146
  • 13
  • 40
  • 131