In this article, we will show how to Validate End date is greater than Start date in Dynamics 365 using JavaScript.

Open Entity main form and select form properties.

In Next step click on “Add” button for add Web Resources.

In new open window click on “New” button.

Enter the name of Web Resources and click on “Text Editor” for write the code. Finally, Save and publish your Web Resources.

Write this Code on Text Editor for Validate End date is greater than Start date in Dynamics CRM and Click On “OK” button.

function ValidateEndDate(executionContext)
{
formContext = executionContext.getFormContext();
var sdate = formContext.getAttribute(“vinay_born”);
var edate = formContext.getAttribute(“vinay_end”);
if (sdate.getValue() > edate.getValue())
{
alert(“End date Cannot be higher than Start date”);
}
}

Select Event Handlers “OnSave” and click on Add button for add function name.

In this step write your function name and click on “OK” button after that finally save the main form and publish.

You can see in below image start date is greater than end date and if you click on Save button alert message is showing.