onChange client script to display confirmation message

brahmapati
Giga Contributor

Hi ,

I ma working on a onChange client script to display error message. Below is my script, when I select the Value '4'   and submit the from the from it should display a info message with options 'Yes' and 'No' , when select 'Yes' for should be updated with value 4 otherwise old value. Any help would be appreciated.

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

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

  return;

  }

var val = g_form.getValue('state');

  if(val == '4')

  {

  g_form.addInfoMessage("Please Confirm that the task should be move back");

  }  

  else {

              g_form.setValue('state',oldValue);

          }

}

thank you,

4 REPLIES 4

tonemking
Giga Expert

Hi,



confirm is the method you want to use. That will give the user an "OK" or "cancel".



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


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


  return;


  }



var val = g_form.getValue('state');



  if(val == 4){


  var answer = confirm("Please Confirm that the task should be move back");


 


  if (answer == false){


  g_form.setValue('state', oldValue);


}


}


}



Tone


brahmapati
Giga Contributor

Thank you Antone,


It i working fine.


Great! be sure to mark the answer as correct if you can.



Best,




Tone


Pradeep J
Kilo Guru

Hi,



in validation part you are using



If(val=='4')



it will treat as string .So change it to val==4 and try



Thanks


Pradeep D J