CRM

Validate End date is greater than Start date in CRM

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

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

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

validate-end-date-greater-start-date-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-greater-start-date-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-greater-start-date-crm

Step 5. Write this Code on Text Editor for Validate End date is greater than Start date in 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-greater-start-date-crm

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

validate-end-date-greater-start-date-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-greater-start-date-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-greater-start-date-crm

Leave a Reply

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