/    Sign up×
Community /Pin to ProfileBookmark

javascript validate problems

i have the following on my site

[code]
<script type=”text/javascript”>

function validate(f) {
if (f.ipbin1.value == 10101100) {
alert (“Well Done, try the next one”);

} else {
alert (“Incorrect, Have another go!”);
}
return false;
}

function validate(f) {
if (f.ipbin2.value == 00111000) {
alert (“Well Done, try the next one”);

} else {
alert (“Incorrect, Have another go!”);
}
return false;
}
function validate(f) {
if (f.ipbin3.value == 11100000) {
alert (“Well Done”);

} else {
alert (“Incorrect, Have another go!”);
}
return false;
}

</script>
[/code]

and then the forms:

[code]<form name =”ipbin1″ onSubmit=”return validate(this)”>
<input type=”text” name=”ipbin1″ size=”8″>
<input type=”submit” value=”Submit” name=”B1″>
</form></td>
</tr>
<tr>
<td width=”249″ bgcolor=”#003366″ align=”left”>
<p align=”left”>Convert 56 into Binary</td>
<td width=”188″>
<p align=”center”>&gt;&gt;</td>
<td><form name =”ipbin2″ onSubmit=”return validate(this)”>
<input type=”text” name=”ipbin2″ size=”8″>
<input type=”submit” value=”Submit” name=”B2″></form></td>
</tr>
<tr>
<td width=”249″ bgcolor=”#003366″ align=”left”>
<p align=”left”>Convert 224 into Binary</td>
<td width=”188″>
<p align=”center”>&gt;&gt;</td>
<td><form name =”ipbin3″ onSubmit=”return validate(this)”>
<input type=”text” name=”ipbin3″ size=”8″>
<input type=”submit” value=”Submit” name=”B3″></form></td>[/code]

Why does the third form validate fine but the first 2 dont?

cheers for any help

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMar 07.2006 — You are trying to use three different functions all with the same name. That is invalid. You either have to use a single function for all three or use three different function names.
×

Success!

Help @cashton2k spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...