How to clear the Error Message popup previously?? (It keeps stacking up when hit the error and the first error unable to clear)

Jason Lau Chang
Giga Contributor

Hi Guys,

I have a OnSubmit Client Scripts as below, tried to add in "g_form.clearMessages();" in order to clear the precious error messages, but it still leaving the first error on top and unable to clear it. (If I remove the "g_form.clearMessages();" , the error will keep stacking up when the user press the Submit button for second / third time etc. 

 

Any suggestion on the ways to clear All the Error PopUp previously then only show the new Error Message (if any) ?? 

 

===================================================================

function onSubmit() {
if(g_form.getValue("Variable_1") == "Yes") {

g_form.clearMessages();
g_form.addErrorMessage("Not suitable for storing Government or Banking data.");

return false;
}

if(g_form.getValue("Variable_2") == "Yes") {

g_form.clearMessages();
g_form.addErrorMessage("Not suitable for storing Highly Confidential Data.");

return false;
}

if(g_form.getValue("Variable_3") == "Yes") {

g_form.clearMessages();
g_form.addErrorMessage("Not suitable for storing Personal Data (Beyond Business card details).");

return false;
}

}

=======================================================================

1 ACCEPTED SOLUTION

Jason Lau Chang
Giga Contributor

Hi Guys,

thanks for trying to help, I have solved this myself by using the OnChange function:

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//When "will you be storing Government Data" selected with "No", it will clear the message
if (isLoading || newValue == 'No') {

g_form.clearMessages();
return;
}

}

View solution in original post

10 REPLIES 10

Narsing1
Mega Sage

Hi,

Can you try like this.

function onSubmit() {

g_form.clearMessages();
if(g_form.getValue("Variable_1") == "Yes") {

g_form.addErrorMessage("Not suitable for storing Government or Banking data.");

return false;
}

if(g_form.getValue("Variable_2") == "Yes") {


g_form.addErrorMessage("Not suitable for storing Highly Confidential Data.");

return false;
}

if(g_form.getValue("Variable_3") == "Yes") {


g_form.addErrorMessage("Not suitable for storing Personal Data (Beyond Business card details).");

return false;
}

}

Hi Narsing,

 

Tried, still the same, any other "ways" ?? 

Thank you.

 

Regards,

Jason Lau

Try

Validating all the getValue() logics under one if loop and in the else loop

g_form.clearMessages(); //clear message here

} //End of function

 

function onSubmit() {

var c=0;

if(c==0)
{
if(g_form.getValue("Variable_1") == "Yes") {

g_form.addErrorMessage("Not suitable for storing Government or Banking data.");
c=1;
return false;
}

if(g_form.getValue("Variable_2") == "Yes") {
c=1;
g_form.addErrorMessage("Not suitable for storing Highly Confidential Data.");

return false;
}

if(g_form.getValue("Variable_3") == "Yes") {
c=1;
g_form.addErrorMessage("Not suitable for storing Personal Data (Beyond Business card details).");

return false;
}

}

g_form.clearMessages();


}