web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

Input verification

(0) ShareShare
ReportReport
Posted on by 171

I have a formula where a colon is set if there is none. This should then be patched into the dataverse. But now I want to catch errors such as only numbers can be entered and then only permissible hours and minutes. eg 23:59 or 2359 should be the highest possible number.

 

 

If(
 Len(inpOrderTimeMonday.Text) > 2 && !(":" in inpOrderTimeMonday.Text),
 UpdateContext(
 {
 locVarColonCheckGalleryMo: If(
 Len(inpOrderTimeMonday.Text) = 3,
 Left(
 inpOrderTimeMonday.Text,
 1
 ) & ":" & Right(
 inpOrderTimeMonday.Text,
 2
 ),
 Left(
 inpOrderTimeMonday.Text,
 Len(inpOrderTimeMonday.Text) - 2
 ) & ":" & Right(
 inpOrderTimeMonday.Text,
 2
 )
 )
 }
 ),
 UpdateContext({locVarColonCheckGalleryMo: inpOrderTimeMonday.Text})
 ;
 Reset(inpOrderTimeMonday);
);

Patch(
 ServiceCapture,
 Defaults(servicecapture),
 {
 Date: DateValue(lblDateMonday.Text, "en"),
 Hours: cmpDateTimeFunctions_1.FormatHoursAsMinutes(locVarColonCheckGalleryMo),
 Note: inpNoteMonday.Text
 }
);

 

Categories:
I have the same question (0)
  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @alt88 ,

     

    I would offer you a better approach to achieve this goal. Please set below formula OnChange of the Text Input box:

    If(
     IsMatch(
     Self.Text,
     "^(?:\d|[01]\d|2[0-3]):[0-5]\d$",
     MatchOptions.Complete
     ) || IsMatch(
     Self.Text,
     "^(?:\d|[01]\d|2[0-3])[0-5]\d$",
     MatchOptions.Complete
     ),
     If(
     Len(inpOrderTimeMonday.Text) > 2 && !(":" in inpOrderTimeMonday.Text),
     UpdateContext(
     {
     locVarColonCheckGalleryMo: If(
     Len(inpOrderTimeMonday.Text) = 3,
     Left(
     inpOrderTimeMonday.Text,
     1
     ) & ":" & Right(
     inpOrderTimeMonday.Text,
     2
     ),
     Left(
     inpOrderTimeMonday.Text,
     Len(inpOrderTimeMonday.Text) - 2
     ) & ":" & Right(
     inpOrderTimeMonday.Text,
     2
     )
     )
     }
     ),
     UpdateContext({locVarColonCheckGalleryMo: inpOrderTimeMonday.Text});
     Reset(inpOrderTimeMonday);
     ),
     Notify("you must enter a valid time format value");
     Reset(inpOrderTimeMonday)
    )

     

    So users need to type in a valid hh:mm or h:mm time format value otherwise the textinput box will reset and notify an error message.

     

    Best regards,

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 883

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 477

Last 30 days Overall leaderboard