how to prevent submit with error message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2023 10:35 PM
i'm using a client script with the below code. I want to popup a error message and prevent submit if my output is false;
var output='';
var req=g_user,userName;
var ent=g_form,getValue('gp_name);
var acc=new GlideAjax('global.app_validate');
acc.addParam(sysparm_name,'validate');
acc.addParam('gp',ent);
acc.addParam('user',req);
acc.getXMLAnswer(function(response){
output=response;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2023 04:35 AM
Hi @Akki1,
Try the alternative (Display Business rule and on submit client scripts) shared by Akshay.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2025 06:47 AM
Hi Akki1 your code is not worked because of the asynchronous behavior of GlidAjax API the glidajax function is execut in last that's why the form is always submitted even the response is true or false so to prevent the form submission you need to used a flag variable like that here's the code
'