web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to add validation to date only field on a form

(0) ShareShare
ReportReport
Posted on by 187

Hi there,

As per requirement, is there a way to add validation to a date only field on a model driven app form so that only today's date and future dates can be selected on the field through OOTB workflow? Or is it easier with applying business rule logic.Any further guidance or method is appreciated, thanks in advance.

I have the same question (0)
  • Suggested answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    RE: How to add validation to date only field on a form

    Hello,

    Unfortunately this is a limitation, But you you can achieve using the customization.

    Please follow below steps.

    1. Create a Date field which should be type as calculated and populate this field with current date.

    pastedimage1651730643916v1.png

    Then click on the edit and apply below Action.

    pastedimage1651730706269v2.png

    2. Add this field on the form and make it as the hidden.

    pastedimage1651730815997v3.png

    3. Then create a business rule and add the below condition.

    pastedimage1651730974076v4.png

    pastedimage1651731003653v5.png

    pastedimage1651731030497v6.png

    So if user will select the Past date then above error will show and it will clear the Date field.

    4. This is how it will show if user will select the Past date.

     pastedimage1651731088071v7.png

    Thank you,

    Amit Katariya

  • Sol007 Profile Picture
    187 on at
    RE: How to add validation to date only field on a form

    Thanks Amit Katariya, will give this a try. I thought this may not be completely achieved by Business rule and was trying to avoid any coding but started looking if applying js code onload of the form would achieve it.

  • Verified answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    RE: How to add validation to date only field on a form

    Hello,

    I have try to implement above scenario with the JS Code But the issue arises when you will try to add the code on change of field.

    I have already tried this solution but because of on change event the pop up was showing multiple times...…and we can not avoid it. So Business rule will be the best solution..,

    Thank you,

    Amit Katariya

  • Sol007 Profile Picture
    187 on at
    RE: How to add validation to date only field on a form

    Hi Amit Katariya, the validation does not appear to work if you enter a past date it is still storing the record on the table. The Now() calculated field seems not to work in BR? Maybe JS?

  • Suggested answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    RE: How to add validation to date only field on a form

    Have you followed all 3 steps which are mentioned in the Business rule. Please consider "Date" field as your existing field and "Today's Date" as the new field(Make it as hidden on the form) which you will need to create.

    pastedimage1651760634459v2.png

    You will need to use Now() function which will populate current date in "Today's Date" automatically because it is calculated field.

    and Last but not least we have BR which will compare existing "Date" field and "Today's Date" field.

    if "Date" field is less than "Today's Date" field then it will clear the "Date" field and also show the error message.

    7725.Animation.gif

  • Sol007 Profile Picture
    187 on at
    RE: How to add validation to date only field on a form

    Hi Amit Katariya, yes I did see screenshot below. When I select a past date on the field I have to click save for the error message to appear and the past date is stored in the record table until I select a current or future date for it to clear.

    BR.jpg

    I am giving js code on the field a try now: please  someone help me with what js function I need to pass for the current date not to error? If I select a past date I get the error notification also when I select a current date (today) I still get same error

    Js-field-date_5F00_LI-_2800_2_2900_.jpg

    Thanks in advance

  • Suggested answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    RE: How to add validation to date only field on a form

    Hello,

    have set the scope of Business rule correctly?

    Because if it is not set correctly then it will not work. you can set as entity/all form/form specific

    pastedimage1651774498763v1.png

  • Sol007 Profile Picture
    187 on at
    RE: How to add validation to date only field on a form

    Hi, the scope of the Business rule is set correctly to form specific.

  • Suggested answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    RE: How to add validation to date only field on a form

    Does both fields Like Old date field and new one is added/ present on the form ?

  • Sol007 Profile Picture
    187 on at
    RE: How to add validation to date only field on a form

    Yes, old date field is visible on the form and new one that was added on the form is hidden.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 109 Super User 2025 Season 2

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 97

#3
#ManoVerse Profile Picture

#ManoVerse 56

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans