0
function onChange(control, oldValue, newValue, isLoading) {  
   if (!isLoading) {  
      if(newValue != '') {  
         //current date  
         var currentDateObj = new Date();  
         var currentDateStr = formatDate(currentDateObj, g_user_date_format);  
         var currentDateNum = getDateFromFormat(currentDateStr, g_user_date_format);  
          //get start date  
         var startDateStr = g_form.getValue('need_by_date_e3_tomcat');  
         var startDateNum = getDateFromFormat(startDateStr, g_user_date_format);  
                           if (startDateNum < currentDateNum) {  
            alert('You cannot select a date in the past.');  
            g_form.setValue('need_by_date_e3_tomcat', '');  
         } 
      }  
   }  
}
Onchange client Script to compare two dates in ServiceNow?
Working Code Asked question July 24, 2023