g_form. clearMessages is not working

Aman22
Mega Contributor

g_form. clearMessages is not working in onSubmit script for a catalog form. I am trying to clear out old messages when user fills in fields and clicks submit. it seems like the old message are not going away. Below is the test script.

 

function onSubmit() {
g_form.clearMessages();
//Type appropriate comment here, and begin script below
g_form.showErrorBox("field1","Test");
return false;
}

6 REPLIES 6

Rawaa
Tera Contributor

g_form.clearMessages() works with the error/info/warning messages on the top of the form but i see here you are showing a field error message

1) fields message:

g_form.showErrorBox('field-name','message') can be removed by g_form.hideErrorBox('field-name')

 

2) Form message: g_form.addErrorMessage('message') can be removed by g_form.clearMessages()

Aman22
Mega Contributor

Thanks @Rawaa 

 

I have tried that as well but the same issue

 

Updated Script  below

function onSubmit() {
g_form.clearMessages();
//Type appropriate comment here, and begin script below
//g_form.showErrorBox("field1","Test");
g_form.showFieldMsg("field1" ,"Test","error");
return false;
}

Hello,

Super old thread but its not working because you need to add a 2nd parameter after the field name:

g_form.hideFieldMsg('move_information', true);

Kind Regards

Ashley

Rawaa
Tera Contributor

Try 

function onSubmit() {
g_form.clearMessages();
//Type appropriate comment here, and begin script below

g_form.hideErrorBox("field1");
g_form.showErrorBox("field1","Test");
//g_form.showFieldMsg("field1" ,"Test","error");
return false;
}