Incident

pavan38
Tera Expert

I am creating a client script for past value restriction on a field on incident form. but not working please help here what is going wrong

on change client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var expDate =new Date(newValue);
    alert(expDate);
   
    var currentDate = new Date();
    alert(currentDate);
    if (expDate < currentDate) {
        //alert('add future date');
        g_form.clearValue('u_awaiting_expiration');
        g_form.showFieldMsg('u_awaiting_expiration','Select future date','error');
       
    }
   

}
 
 
Issue:  alert(expDate);----->this alert is showing wrong in the alert box.. when i select oct 5 2023.. it is showing june 5 2023..
2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @pavan38 

 

You can try below script.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var expDate = getDateFromFormat(newValue, g_user_date_format);
    alert(expDate);
    var currentDate = new Date();
    alert(currentDate);
    if (expDate < currentDate) {
        //alert('add future date');
        g_form.clearValue('u_awaiting_expiration');
        g_form.showFieldMsg('u_awaiting_expiration','Select future date','error');
    }
}

 

Please mark my answer helpful and accept as solution if it helped you t👍✔️

Thanks,
Anvesh

@AnveshKumar M Thanks for the input but the alert is showing 0..not working