g_form. clearMessages is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 03:04 PM
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;
}
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 03:23 PM
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()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 03:29 PM
Thanks
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 03:40 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 03:37 PM
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;
}