/    Sign up×
Community /Pin to ProfileBookmark

mozilla incompatibility

The script below works only in IE and not in mozilla.. can anyone help me out !!

I think the problem is due to [B]event.returnValue=false;[/B], which is windows specific.

[QUOTE]

<HTML>
<HEAD>
<TITLE>Validating Large Radio Fields</TITLE>
</HEAD>
<BODY>
<FORM ID=”mainform” ACTION=”http://prem” METHOD=”post” onsubmit=”validate();”>
<BR>
<INPUT TYPE=”RADIO” NAME=”IceCream” VALUE=”Vanilla”>Vanilla
<INPUT TYPE=”RADIO” NAME=”IceCream” VALUE=”Choc”>Chocolate
<INPUT TYPE=”RADIO” NAME=”IceCream” VALUE=”Straw”>Strawberry
<INPUT TYPE=”RADIO” NAME=”IceCream” VALUE=”RaspR”>Raspberry Ripple
<INPUT TYPE=”RADIO” NAME=”IceCream” VALUE=”Mint”>Mint
<BR>
<INPUT TYPE=”SUBMIT”>
</FORM>

<SCRIPT>
<!–
function validate() {
ICOK=false;
for (ic=0;ic<5;ic++) {
if (document.getElementById(“mainform”).IceCream[ic].checked) ICOK=true;
}
if (!ICOK) {
alert(‘Your favorite Ice Cream flavor is a required field. Please try again.’);
event.returnValue=false;
}
}

// WORKS IN IE not in MOZILLA
–>

</SCRIPT>
</BODY>
</HTML>

[/QUOTE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 18.2004 — Change [i]onsubmit="return validate();"[/i]

and
if (!ICOK) {
alert('Your favorite Ice Cream flavor is a required field. Please try again.');
return false;
}
Copy linkTweet thisAlerts:
@drahulauthorOct 18.2004 — thanks Fang !!

it works in bot mozilla and IE.?
×

Success!

Help @drahul 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...