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

It will display error message and abort submission, so user has to make changes and submit/add to cart again. Then it clears that message and submits if there is no issue or display error again if condition is satisfied.

Is the requirement different?

agblog
Kilo Explorer

I used but 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();

}
}

Sateesh Kumar 2
Kilo Guru

Make sure Use Maxwell's script on  first line of your onsubmit script.

Miss placing it would bring wrong results.