- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2020 07:50 PM
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;
}
}
=======================================================================
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-05-2020 04:50 PM
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;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2020 08:18 PM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2020 10:25 PM
Hi Narsing,
Tried, still the same, any other "ways" ??
Thank you.
Regards,
Jason Lau

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2020 10:32 PM
Try
Validating all the getValue() logics under one if loop and in the else loop
g_form.clearMessages(); //clear message here
} //End of function

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2020 10:44 PM
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();
}