Hide Error Message on Client Script

agblog
Kilo Explorer

I have a self service catalog form which has many flows depending upon users "Yes" and "No" selection. For the last Yes/No selection, if user selects "No" and clicks "Add To Cart" then a Error message shows up "Sorry! You cannot complete this transaction"  at the top of the screen. I want if this "No" condition is false i.e if user selects Yes or changes and any other previously selected Yes/No option then the Error Message should hide/go away. How can I achieve that?

Here is the Client Script:

function onSubmit() {
//Type appropriate comment here, and begin script below
var a1 = g_form.getValue('X');

if (a1== 'No'){
g_form.addErrorMessage('Sorry! You cannot complete this transaction.');
return false;
}
}

Thanks!

7 REPLIES 7

maxwell_kruse
Giga Contributor

I did, still it did not work

 

function onSubmit() {
//Type appropriate comment here, and begin script below
var a1 = g_form.getValue('X');

if (a1== 'No'){
g_form.addErrorMessage('Sorry! You cannot complete this transaction.');
return false;
}

else{

g_form.clearMessages();

}
}

Hi

You can clear messages first every time onSubmit runs and show error message in answer in NO and return false.

 

function onSubmit() {
//Type appropriate comment here, and begin script below

g_form.clearMessages();

var a1 = g_form.getValue('X');

  if (a1== 'No'){
     g_form.addErrorMessage('Sorry! You cannot complete this transaction.');
     return false;
  }

}

It removed my predefined message box but not removing this error message box.