Abort client script onsubmit

Mr Bow
Kilo Expert

Hi there,

i have the following script include:

 

 

find_real_file.png

 

and i have the following client script: 

find_real_file.png

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?

 

12 REPLIES 12

Priyanka Gupta
Mega Guru

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 Skinner
Mega Guru

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.

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

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;
	}