/    Sign up×
Community /Pin to ProfileBookmark

firefox ignores javascript validation function. OK in IE

HI;

I would really appreciate help as after two hours of trying to solve problem, i’m still stumped. Validation of several input fields work fine on IE, but foxfire ignores it. I’ve simplified but even one field doesn’t get validated.
Note: Javascript is turned on + it validates other pages as expected.

thanks so much!

steve
=======

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″ />
<title>payment2</title>
<script type=”text/javascript” language=”Javascript”>
function check_data(payment)

{var perror=false;
cctypeindex=payment2.cctype.selectedIndex;

if (cctypeindex == 0)
{alert (“Credit Card Type Not Selected….Please Select Card Type.”);
perror=true;
}

if (perror) {return false;}
else {return true;}
}

</script>
</head>
<body>
<form name=”payment2″ action=”Payment3.php” method=”post”
onsubmit=”return check_data(this)” >
<table width=56% height=”152″ border=”1″ cellpadding=”00″ cellspacing=”0″ bordercolor=”#009999″ >

<td height=”29″ colspan=”3″ valign=”middle” bgcolor=”#009999″>CREDIT CARD INFORMATION</td>
</tr>

<tr>

<td width=”48%” height=”27″ valign=”middle” bgcolor=”#00CCCC”>Credit Card Type:</td>
<td width=”52%” height=”27″ valign=”middle” bgcolor=”#00CCCC”>
<select name=”cctype” size=”1″ id=”cctype”>
<option>Please Select</option>
<option value=”VISA”>Visa</option>
<option value=”MC”>Master Card</option> </select> </td></tr>

<tr>
<td align=“left height=“23”>
<input type=”submit” name=”submit” value=”CONTINUE” />
</td>

</tr>
</form>
</table>

</body>
</html>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Logic_AliApr 22.2007 — HI;

I would really appreciate help as after two hours of trying to solve problem, i'm still stumped. Validation of several input fields work fine on IE, but foxfire ignores it.[/quote]
No it doesn't - you are ignoring the FireFox error console.
[CODE]cctypeindex=payment2.cctype.selectedIndex;[/CODE]
You cannot refer to a form directly by name.

document.forms.formName.
Copy linkTweet thisAlerts:
@livebymyheartauthorApr 23.2007 — Thanks for writing, but I'm still confused. Could you be a little more specific?

if my top level form name was "toplevel" and I had a text input form named "text1" and I had a select box named "state" with 50 values,

how would I Reference them to determine if "text1" was empty and "state" was selected.
Copy linkTweet thisAlerts:
@livebymyheartauthorApr 23.2007 — I finally got it. The problem was I tried to test the input value using "payment2" as part of the reference.

(cctypeindex=[I]payment2[/I].cctype.selectedIndex?

but since my function was defined with "payment" as the passed parameter

[i.e. function check_data(payment)] firefox did not recognized it. IE is more liberal, i suppose, assuming anything refering to a single parameter is acceptable.

thanks for the help.
×

Success!

Help @livebymyheart 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.19,
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,
)...