Hi,
I have a form that has a datepicker and I would like my users to be able to pick only today or past dates and not the future dates.
Can you please help.
Appreciate your help.
Ghasem
Solved! Go to Solution.
The date picker itself currently doesn't have that capability (please create a new feature request in the PowerApps Ideas page for that)
What you can do is to notify (visuall) the user that this is an invalid entry. For example, in the app shown below, when the date is selected the border of the picker is changed and an error message is displayed:
This can be accomplished by setting the properties below:
DatePicker1.BorderColor: If(DatePicker1.SelectedDate > Today(), Color.Red, RGBA(101, 128, 187, 1))
Label1.Text: "Dates in the future cannot be selected"
Label1.Color: Color.Red
Label1.Visible: DatePicker1.SelectedDate > Today()
Notice that you can also use similar expressions to prevent the user from submitting a form (in the element that causes the form submission, you can set its 'Disabled' property to DatePicker1.SelectedDate <= Today(), for example).
The date picker itself currently doesn't have that capability (please create a new feature request in the PowerApps Ideas page for that)
What you can do is to notify (visuall) the user that this is an invalid entry. For example, in the app shown below, when the date is selected the border of the picker is changed and an error message is displayed:
This can be accomplished by setting the properties below:
DatePicker1.BorderColor: If(DatePicker1.SelectedDate > Today(), Color.Red, RGBA(101, 128, 187, 1))
Label1.Text: "Dates in the future cannot be selected"
Label1.Color: Color.Red
Label1.Visible: DatePicker1.SelectedDate > Today()
Notice that you can also use similar expressions to prevent the user from submitting a form (in the element that causes the form submission, you can set its 'Disabled' property to DatePicker1.SelectedDate <= Today(), for example).
Forgive my ignorance, but where do we set these properties? I'm new to PowerApps, but where do we set these properties:
DatePicker1.BorderColor: If(DatePicker1.SelectedDate > Today(), Color.Red, RGBA(101, 128, 187, 1)) Label1.Text: "Dates in the future cannot be selected" Label1.Color: Color.Red Label1.Visible: DatePicker1.SelectedDate > Today()
There are so many properties to "set" in PowerApps and I get incredibly confused. I'm very, very familar with InfoPath, but my client asked if I could look into doing a validation for a date field. I think I can modify this code to fit what I need, which is to have the date field only allow dates that are at least 3 weeks out. For instance, users cannot put in a date that is less than 3 weeks away.
In this example, there are two controls (named DatePicker1 and Label1). If you select one of the controls (for example, the Label1), you can go either to the formular bar and select the appropriate property (again, in the example you'd choose 'Text', 'Color' and 'Visible'):
Or to the Advanced tab in the right-side pane (this screenshot in Portuguese, but it would be similar for English or other languages):
Hope this helps!
Carlos,
I appreciate the response, but after going through the date field advanced tab, I do not see a Text field. Please see the attached screenshot. What I'm trying to edit, is not a label, but instead a date picker field. There is not a "text" field to edit when the date picker field is selected.
UPDATE: I have successfully added a label. The issue was me trying to make changes to the date field, when I needed to add a label to mask over the field. I was under the impression it was a validation step, but it's just a formatting step. The users *could* potentially submit a date that is not allowed, but the submit button may be my next step to prevent that.
User | Count |
---|---|
256 | |
111 | |
95 | |
48 | |
40 |