How to validate end date to be greater than start date
function ValidateMaintenanceEndDate(executionContext)
{
var formContext = executionContext.getFormContext();
var startDateField = formContext.getAttribute("new_maintenancestart");
var endDateField = formContext.getAttribute("new_maintenanceend");
var endDateFieldControl = formContext.getControl("new_maintenanceend");
var startDate = startDateField.getValue();
var endDate = endDateField.getValue();
if (startDate != null && endDate != null)
{
startDate = new Date(startDate.toISOString().substr(0, 10));
endDate = new Date(endDate.toISOString().substr(0, 10));
endDateFieldControl.clearNotification("ErrEndDate");
if (startDate >= endDate)
{
endDateFieldControl.setNotification("cannot be before or equal to Maintenance Start.", "ErrEndDate");
}
else
{
endDateFieldControl.clearNotification("ErrEndDate");
}
}
}
No comments:
Post a Comment