Cross-Browser JavaScript Issue

GilesGuthrie

Staff Emeritus
11,038
United Kingdom
Edinburgh, UK
CMDRTheDarkLord
OK, I have a form on a page, called form1. The HTML opening tag for the form is thus:
PHP:
<form name="form1" method="post" action="register.php" onSubmit = "return checkForm(this)">

In the form are a number of fields, which I want to validate using Javascript. So here's my script, for one of the fields only (all the others are [snip]ped out to save space.

PHP:
<script language="JavaScript1.1">
<!-- Hide from Stupid Browsers

function checkForm(rf)
{
	// Check they entered a username
	if (rf.username.value == "")
	{
		alert("Please enter a Username")
		form1.username.focus()
		return false
	}
[snip]
	// Well we got here, so it must be cool.
	rf.verified.value = 1
	return true
}
--></script>

In IE, this works fine. That is to say that if the username field is blank, an alert pops up and the page remains on-screen. It works in all fields.

However, in Mozilla Firebird 0.61, it doesn't quite work. The alert is thrown, suggesting that the script has caught the error, but when you hit OK on the alert, the form handler is called anyway.

Anyone got any ideas?
 
Mozilla, is pretty behind in alot of things. It was unable to load my flash menu.

I'm thinking, there's nothing wrong with the script it's just Mozilla.
 
Originally posted by Super-Supra
Mozilla, is pretty behind in alot of things. It was unable to load my flash menu.

I'm thinking, there's nothing wrong with the script it's just Mozilla.
You obviously don't have Flash installed. And before you go jumping down my throat, there is Flash for IE and there is Flash for Netscape/Mozilla.
 
Originally posted by Super-Supra
Mozilla, is pretty behind in alot of things. It was unable to load my flash menu.

I'm thinking, there's nothing wrong with the script it's just Mozilla.

But that's pretty much the point. If you can get it working on Mozilla, it'll likely work on any browser.

[EDIT] I've just tested the above code on Opera 7.11, and it works to my satisfaction. So it's just a Mozilla thing then...
 
Originally posted by GilesGuthrie
But that's pretty much the point. If you can get it working on Mozilla, it'll likely work on any browser.

[EDIT] I've just tested the above code on Opera 7.11, and it works to my satisfaction. So it's just a Mozilla thing then...
I always thought Opera had worse support than Netscape browsers (Mozilla included).:confused:
 
Back