Hide Error Message on Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2020 02:15 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2020 08:29 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2020 03:26 PM
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();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2020 07:23 PM
Make sure Use Maxwell's script on first line of your onsubmit script.
Miss placing it would bring wrong results.