cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Adam5
New Member

Adding validation to time sets

Does anyone know how to add validation that would ensure that a user could only input a time from between 9:00 and 11:00??

2 REPLIES 2
mdevaney
Super User
Super User

@Adam5 

Choosing the proper control type is key to limiting input values for time.  I would suggest a dropdown instead of a text input. 

 

Create 2 new dropdowns and put this code within the items property.

DropdownHour.Items: ["09,"10","11"]
DropdownMinute.Items: If(DropdownHour.Selected.Value="11",["00"],["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"
])

 

To store this result as a text string you would use this code in the Update property of your form

DropdownHour.Selected.Value&":"&DropdownMinute.Selected.Value&"AM

 

Or to store this result as time you would use this code

Time(Value(DropdownHour.Selected.Value),Value(DropdownMinute.Selected.Value),0)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

v-siky-msft
Community Support
Community Support

Hi @Adam5 ,

 

You can add modify the ErrorMessage of data card to show the error information when the entry time is out of 9-11.

And set the Mode of Submit button, if the there is a Error Message, the button would be disabled.

Text of ErrorMessage in Data card:

 

If(TimeValue(DataCardValue1.Text)>TimeValue("11:00") || TimeValue(DataCardValue1.Text)<TimeValue("9:00"),"out of 9:00-11:00",Parent.Error)

 

DisplayMode of Submit button:

 

If(IsBlank(ErrorMessage1),DisplayMode.Edit,Disabled)

 

StoG_8.gif

Best regards,

Sik

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,891)