Unable to Select the Current date

msm4
Mega Guru

Hi Team,

Please find the below snippet i used to validate the date field to select only the current and future date.

But the problem is im unable to select the current date.

Please guide where i m wrong.

function onChange(control, oldValue, newValue, isLoading) {

if (isLoading || newValue == '') {

          return;

    }

var today = new Date();

var dateMS = today.getTime();

var current_date = new Date();

current_date.setTime(dateMS);

var new_date = new Date(getDateFromFormat(newValue, g_user_date_time_format));

g_form.setValue('ftr_needed_by',formatDate(current_date,g_user_date_time_format));

if(new_date>=current_date)

{

// this is valid

}

  else{

  alert("selected date should be current date or future date");

  g_form.setValue('axa_asia_ph_var_date_needed','');

}

}

Thanks in Advance

1 ACCEPTED SOLUTION

Harneet Sital
Mega Sage
Mega Sage

Hi,



Rather than client script use the following UI policy with the following condition :



Capture.PNG



Write following script :


function onCondition() {


      g_form.setValue('date_of_joining', "'');


      alert("Enter valid date");


}



Its simple and works in all the cases.


View solution in original post

10 REPLIES 10

Many Thanks Harneet...Its working short n sweet