cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper IV
Helper IV

How to validate Data Picker field

Hi Mates,

I would like to validate the Date Field.

Condition1. When the field is blank mean if the User has not selected any value then it should display the Custom text "Date is required "

Condition 2. When User selected Future date means  Today or Past but  not future date, then it should display like "Only today or Past "

 

If you understand here

Condition 1 validation has to trigger when only hit the submit button because when the user entered into the new screen it should not display until unless hit the button to save.

Condition2 has to display if the user selects only the Future date. 

 

I have already tried for both i don`t work

condition2, it's working fine

ErrorMessage Text property "Only today or Past ",

ErrorMessage Visible: If(date.Selected >=Today+1,true,false)

 

but I would like to integrate with both 

Condition 1 what I have tried 

On-Screen Visible
UpdateContext({showDate: Blank()})

Button on selected 

UpdateContext({showDate: "Date is requred"})

 

Now

Error message Text property is updated with below 

If(IsBlank(Date.SelectedDate), ShowDate, "Date Should be Today")

Visible property I am not sure but just tried with below 

And(Parent.Valid,Date.SelectedDate >= Today()+1)

Here only Condition 2 is working but not condition 1 Means

when I select the future date it shows "Date should be Today"

But without entering when I try to submit it's not showing any ting and it allows to saving. 

 

 

any help, how can it works with both.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@muralikrishna12 

Consider the following to achieve what you want.

UpdateContext({lclMessage: If(IsBlank(Date.SelectedDate), "Date is Required", Blank())})
If(IsBlank(lclMessage), SubmitForm(yourForm)

Set the Text property of your error message label to the following:

Coalesce(lclMessage, If(Date.SelectedDate > Today(), "Only today or Past"))

 

Set the DisplayMode of your submit button to the following:

If(yourFormName.Valid, Edit, Disabled)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

1 REPLY 1
Super User III
Super User III

@muralikrishna12 

Consider the following to achieve what you want.

UpdateContext({lclMessage: If(IsBlank(Date.SelectedDate), "Date is Required", Blank())})
If(IsBlank(lclMessage), SubmitForm(yourForm)

Set the Text property of your error message label to the following:

Coalesce(lclMessage, If(Date.SelectedDate > Today(), "Only today or Past"))

 

Set the DisplayMode of your submit button to the following:

If(yourFormName.Valid, Edit, Disabled)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (61,368)