CRM

Validate End date is greater than Start date in Dynamics CRM

In this blog, we will learn about the Validate End date is greater than Start date in Dynamics CRM.

In this article, we will learn the Validate End date is greater than Start date in Dynamics CRM using JavaScript.

Step 1. Open Entity main form and select form properties.

Validate End date is greater than Start date in Dynamics CRM

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

validate-end-date-greater-start-date-crm

Step 3. In new open window click on “New” button.

Validate End date is greater than Start date in Dynamics CRM

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

Validate End date is greater than Start date in Dynamics CRM

Step 5. Write this Code on Text Editor for Validate End date is greater than Start date in Dynamics CRM and Click On “OK” button.
[php]
function validateStartdateEndDate()
{
var startdate = Xrm.Page.getAttribute("cr39f_startdate").getValue();
var enddate = Xrm.Page.getAttribute("cr39f_enddate").getValue();
if(startdate > enddate )
{
alert("End date should be greater than or equal to the start date.");
}
}
[/php]

Validate End date is greater than Start date in Dynamics CRM

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

Validate End date is greater than Start date in Dynamics CRM

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

Validate End date is greater than Start date in Dynamics CRM

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

Output

Validate End date is greater than Start date in Dynamics CRM

Leave a Reply

Your email address will not be published. Required fields are marked *