Simple client script to validate if end date is after start date.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//get the entered date string
var startDate = g_form.getValue('starts');
var endDate = g_form.getValue('ends');
var startDateValue = new Date(startDate).valueOf();
var endDateValue = new Date(endDate).valueOf();
//Compare the two numbers
if (startDateValue > endDateValue) {
alert('End date must be after start date.');
g_form.setValue('ends','');
}

Leave a comment