Abort client script onsubmit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 02:41 PM
Hi there,
i have the following script include:
and i have the following client script:
What i want is that if my script include return empty the client script abort and if its not empty the client script let the user submit the form. right now its working fine the include but there is something wrong with my client script as its always aborting with the line 13 in my code. any ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 02:49 PM
Hi,
In your client script, return false should be right after the brackets of if close. Your return false is outside the function Process, which is why it is always running.
Here's how it should look like-
function Process(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer!=''){
return true;
}
return false;
}
Please mark my answer helpful/correct if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 02:51 PM
Hi,
From the look of it the return False; is always running.
You should have something like this.
if (answer != ' '){
return true;
}
else {
return false;
}
If this helps please mark as helpful, if this answered your question please mark as answered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 02:56 PM
function onSubmit(){
var ga = new GlideAjax('getMangerName');
ga.addParam('sysparm_name','getManager'); // pass script include function
ga.addParam('sysparam_id',g_user.userID);
ga.getXML(Process);
var answer;
function Process(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer != ''){
return true;
}
return false;
}
}
i have tried this but its letting me submit the form if the include answer is empty and if its not

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 02:59 PM
Convert your answer to String like this and see if it helps-
function Process(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer.toString() != ''){
return true;
}
return false;
}