简体   繁体   English

文本输入框电源应用程序中的日期和时间验证

[英]date and time validation in text inputbox power apps

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我创建了一个新的强大应用程序:在应用程序中,一个文本输入字段用户将更新日期和时间值 Ex 格式:29/12/2022 10:30 AM

Before saving the data I need to validate the format like (DD/MM/YYYY HH:MM AM/PM).在保存数据之前,我需要验证格式,例如 (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.如果用户输入错误的格式需要通过错误消息或突出显示该字段,您能否请一些帮助。

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().然后,您可以将输入组合成一个日期时间值,并根据需要使用 Text() 对其进行格式化。 The necessity to validate formats is elimated.消除了验证格式的必要性。

Try this code in OnChange property of the text box.在文本框的 OnChange 属性中尝试此代码。

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) )如果 (.IsMatch(TextInput1,Text:"\d{2}/\d{2}/\d{4} (1[0-12][1-9]),[0-5][0-9 ] ([AaPp][Mm])" ): Notify("请输入 DD/MM/YYYY 00,00 AM/PM 格式"。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. Output:如果您输入正确的格式(01/02/2023 11:00 AM),它将移至下一个字段,否则会显示通知错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM