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.
Step 2.In Next step click on “Add” button for add Web Resources.
Step 3. In new open window click on “New” button.
Step 4. Enter the name of Web Resources and click on “”Text Editor” for write the code. Finally Save and publish your Web Resources.
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]
Step 6. Select Event “OnSave” and click on Add button for add function name.
Step 7. 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.
Output