Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onsubmit question

Status
Not open for further replies.

sborny

Technical User
Jun 29, 2001
157
GB
Hi,

I have an HTML form that Javascript buitl in to it.

When you press submit you then call the javascript function.
ie: onsubmit="VerifyData();"

Is it possible to have 2 different javascript functions being called when you submit.

Cheers

Symon.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Sure. Just delimit them with semicolons. To further your example:
Code:
onsubmit="VerifyData(); SendForm();"
Hope it helps.
 
I don't think you can call two separate functions. However, you can call one function which then calls two separate functions. How 'bout this:
Code:
onsubmit="[blue]return[/blue] VerifyData();"
Code:
<script language="JavaScript" type="text/javascript">
<!--
function FirstFunctionCall(){
	[green]//If data is valid, return true
	//Else, return false[/green]
}

function SecondFunctionCall(){
	[green]//If data is valid, return true
	//Else, return false[/green]
}

function VerifyData(){
	if (FirstFunctionCall() && SecondFunctionCall()){
		return true;
	}else{
		return false;
	}
}
//-->
</script>
Notice the "return". This will return true or false. If "true" is returned, then the process continues. If "false" is returned, then the process halts.

Hope that helps.
Ron

“If you are irritated by every rub, how will you be polished?”
~ Mevlana Rumi


Do you live in Michigan? Join us in the Tek-Tips in Michigan forum.
 
Hmm. Guess I was wrong about the two separate function calls. Oh well, my solution would probably work too. Thanks, Vragabond.

Ron

“If you are irritated by every rub, how will you be polished?”
~ Mevlana Rumi


Do you live in Michigan? Join us in the Tek-Tips in Michigan forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top