GilesGuthrie
Staff Emeritus
- 11,038
- Edinburgh, UK
- CMDRTheDarkLord
OK, I have a form on a page, called form1. The HTML opening tag for the form is thus:
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.
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?
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?