Click to See Complete Forum and Search --> : keep gettin all alerts twice


TheOnlyCreature
01-13-2003, 02:29 PM
I'm working on a javaScript for a school assignment, but every alert on the page pops up twice. Anyone know how to solve my little problem? The script is jotted down below, just copy and paste it into a blank htm file. Also; the text strings are in dutch, but those aren't that important. The script just checks if three text boxes contain any data.<html>

<head>
<title> Jeffrey Hendriks CSV1B </title>
</head>

<body>
<FORM NAME="Invoer" onSubmit="return checkNAW()">
<INPUT TYPE="text" NAME="naam"> Voer uw naam in. <br>
<INPUT TYPE="text" NAME="adres"> Voer uw straat en huisnummer in. <br>
<INPUT TYPE="text" NAME="woonplaats"> Voer uw woonplaats in. <br>
<INPUT TYPE="text" NAME="postcode"> Voer uw postcode in. <br>
<INPUT TYPE="text" NAME="studierichting"> Voer uw studierichting in. <br>
<br>
<INPUT TYPE="submit" VALUE="Bewerk gegevens" NAME="startCheck" onClick="checkNAW()">
<INPUT TYPE="reset" VALUE="Leeg maken" NAME="maakLeeg">
</FORM>
</body>

<script language="JavaScript">
<!--

function checkNAW()
{
if (Invoer.naam.value == "")
{
alert("U moet een naam invullen.");
Invoer.naam.focus();
return (false);
}
else
{
if (Invoer.adres.value == "")
{
alert("U moet een adres invullen.");
Invoer.adres.focus();
return (false);
}
else
{
if (Invoer.woonplaats.value == "")
{
alert("U moet een woonplaats invullen.");
Invoer.woonplaats.focus();
return (false);
}
else
{
return (true);
}
}
}
}

//einde verbergen -->

</script>

</html>

khalidali63
01-13-2003, 02:49 PM
Get rid of this part of the code from the line below

onSubmit="return checkNAW()">

<FORM NAME="Invoer" onSubmit="return checkNAW()">

Reason.
When button is clicked it submits the form so it caalls checkNAW() method twice once from the submit button and the from forms onsubmit event

Khalid

TheOnlyCreature
01-13-2003, 02:52 PM
That worked, thanks a lot. Stupid me, for not noticing.