PDA

View Full Version : Call 2 funcs simultaneously..??



icehammer
Mar 7th, 2007, 02:38 PM
i have declared two funcs, one in the head.. other in body.
For execution, both these funcs require that i add a "onSubmit="doTHis()" to the <form> tag.

Now, there are two funcs. How do i call them both? I tried this:


function do Both() {
return checkbae();
return checkrequired(this);
}

and:


<form onSubmit="return doBoth()">.


nothing happens.
what to do??

Philip M
Mar 7th, 2007, 03:00 PM
function do Both() {

See anything wrong?

icehammer
Mar 7th, 2007, 03:24 PM
that's a typo.. it doesn't work..

icehammer
Mar 7th, 2007, 03:27 PM
ere's the code:
Both funcs are now declared in body, and only onw works when <form
onSubmit="return checkbae()"> OR <form onSubmit="return checkrequired(this)">.

How do i get them both to function??



<head>
<title> da GMKK zOne. </title>
<link rel="stylesheet" type="text/css" href="../sources/cssstyles.css" />
</head>

<body bgcolor="black">


<center>
<div id="header">
<image src="../images/logo.jpg" alt="Logo" height="150" width="500" />
</div>
<div id="xcept">
<h2>Register</h2>
<hr>

<form name="validation" method="post" action="reguser.php" onSubmit="return checkbae()">
<script language="JavaScript1.2">

var testresults
function checkemail(){
var str=document.validation.emailcheck.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Please input a valid email address!")
testresults=false
}
return (testresults)
}

function checkbae(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true
}


function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!")
return false
}
else
return true
}
</script>



<table align="center">
<tr>
<td align="right">
Username:
</td>
<td>
<input type="text" name="requiredchatter" size="15"><br>
<small>max 15 characters</small>
</td>
</tr>
<tr>
<td align="right">
Password:
</td>
<td>
<input type="password" name="requiredpassword" size="15">
</td>
</tr>
<tr>
<td align="right">
Retype Password:
</td>
<td>
<input type="password" name="requiredpass2" size="15">
</td>
</tr>
<tr>
<td align="right">
Name:
</td>
<td>
<input type="text" name="requiredfname" size="15">
<br><small>first</small>
</td>
<td>
<input type="text" name="requiredlname" size="15">
<br><small>last</small>
</td>
</tr>
<tr>
<td align="right">
E-mail address:
</td>
<td>
<input type="text" name="emailcheck" size="20">
</td>
</tr>
</table>
<br>
<table align="center">
<tr>
<td>
<input type="submit" value="Submit">
</td>
<td>
<input type="reset" value="Clear">
</td>
</tr>
</table>
</form>
<script type="text/javascript">
document.forms[0].chatter.focus();
</script>
</div>
<br><br><div id="footers">
<table border=0 cellspacing=0 cellpadding=0 width="600" align="center">
<tr>
<td valign="center">
<script language=JavaScript>
document.write("You are currently using <b>"+navigator.appName+"</b>.<br>Screen Resolution: <b>"+screen.width+" x "+screen.height+"</b>.");
</script>
<br><br>
Copyright &copy; 2007, Apoorv Chandra. All Rights Reserved.<br>Reproduction of this work in any form is prohibited.<br><b>It's Hard Work.</b>
</td>
<td width=108 valign="center">
<img border="0" alt="Firefox 2" title="Firefox 2" src="../images/firefox.png"/>
<hr />
<img width="88" height="31" border="0" alt="Chipmunk Scripts" title="Chipmunk Scripts" src="../images/chipmunk.gif"/>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>

glenngv
Mar 7th, 2007, 04:36 PM
<form onsubmit="return checkbae() && checkrequired(this)">