Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

DatePicker with Default Date and Validation on OnChange Only

I have a custom SharePoint List customised through PowerApps.  I am facing two issues and wonder if someone could help here.  The StartDate has a default value (today()) but EndDate don't.  

OnStart of the FormScreen1, I have got the following varilable:


Set(vStartInvalidDate, false); Set(vEndInValidDate, false)

OnChange of the DatePicker, I have the following, to validate if selected date is in the past.


If(dpAccessStartDate.SelectedDate<Today(),Set(vStartInvalidDate, true ),Set(vStartInvalidDate, false ))

 On Visible property for the Label:

Or(vStartInvalidDate, DisplayMode = Edit)

1) When I add a new entry, the form shows the error label on the for EndDate.  How doI stop showing this error label until OnChange event fires?

2) Edit Form has entries which were valid at the time, but when I edit an item with past date, it shows the error label.  I want to validate only OnChange event rather than on start with Edit or New form? 


Is there a way to achieve this?





Community Support
Community Support

Hi @smerchatn,


The OnVisible property of your Label should be:

If(And(vStartInvalidDate=true, Form1.DisplayMode = Edit),true,false)



Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-monli-msft  Thanks for a response.  I tried this still doesn't work.  I am on SharePoint Form so assumed you meant SharePointForm1 rather than Form1.


        vStartInvalidDate = true,
        SharePointForm1.DisplayMode = SharePointForm1.DisplayMode.Edit

I noticed that as soon as the Form gets visible, the value for my variable gets changed automatically to true if the selected date (in the existing item) in the edit form has past.  Something is triggering 'OnChange' event without me asking...!


@v-monli-msft, Any update on this, I need to know if this is possible or not so appreciate your help. Thanks


There is a known issue with Datepicker in SharePoint form where OnChange is being fired on load, without the user actually changing the date. Workaround is to only perform OnChange() event if the user actively selects a date, or if the form item has not changed (i.e. we haven't navigated to a new form item).


So change DatePicker OnChange function to something like:


    (DataCardValue.SelectedDate <> SharePointForm.Current.ValueHoldingDate) || (lastFormItemID = SharePointForm.Current.ID),
    // put action here that should be performed on *real* OnChange


Helpful resources

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,556)