
If(
!IsBlank(Parent.Error),
"End Date is required",
DateDiff(
DataCardValue54.SelectedDate,
DataCardValue55.SelectedDate,
TimeUnit.Days
) > 30,
"The End Date field cannot be less than 30 days from StartDate",
""
)
Hi,
What you're seeing is by design. In Power Apps Edit forms, only two things actually block SubmitForm:
Required field is empty (this is why your “End Date is required” works).Valid property is false — which is the aggregate of every DataCard's Valid property.The DataCard's ErrorMessage / Error text property is display-only — it just shows red text under the card. It does not affect Valid, so SubmitForm happily submits anyway. That's why your 30-day rule is “bypassable”.
Valid property reflect your ruleOn the End Date DataCard, set the Valid property to something like:
!IsBlank(DataCardValue55.SelectedDate) &&
DateDiff(DataCardValue54.SelectedDate, DataCardValue55.SelectedDate, TimeUnit.Days) <= 30
Now the card is only Valid when End Date is filled and within 30 days of Start Date. Because the form's overall Valid is the AND of all DataCards, SubmitForm will refuse to run until the rule is met.
Leave your existing ErrorMessage formula (or simplify it) so the user sees why it's blocked:
If(
IsBlank(DataCardValue55.SelectedDate),
"End Date is required",
DateDiff(DataCardValue54.SelectedDate, DataCardValue55.SelectedDate, TimeUnit.Days) > 30,
"The End Date cannot be more than 30 days from Start Date",
""
)
Per Microsoft Learn, the recommended pattern is to guard the submit button itself:
DisplayMode → If(SubmitFormName.Valid, DisplayMode.Edit, DisplayMode.Disabled)OnSelect → If(SubmitFormName.Valid, SubmitForm(SubmitFormName))This prevents the user from even clicking submit while any DataCard is invalid.
📚 Reference: Edit form and Display form controls in Power Apps — SubmitForm & Valid (Microsoft Learn)
Found this helpful? Please mark ✅ “Does this answer your question?” so others searching for the same issue can find it quickly. A 👍 on “Was this reply helpful?” or a ♥ Like is also much appreciated!
Raghav Mishra — LinkedIn | PowerAI Labs