View Full Version : Problem getting form to work in FF

07-08-2011, 11:49 AM
Hi guys I'm having trouble with my javascript coding. The form works fine in IE but does not work in firefox I've been pulling my hair out overt his for the last hour and can't figure it out.

<script type="text/javascript">


function validate_form ( )
valid = true;

if ( document.getElementById.rego_form.First_name.value == "" )
//Alert the user to
alert ( "Please fill in your first name." );
valid = false;

if ( document.getElementById.rego_form.Last_name.value == "" )
//Alert the user to
alert ( "Please fill in your last name." );
valid = false;
//Check Age
if (parseInt(document.getElementById.rego_form.Age.value) < 16 || parseInt(document.rego_form.Age.value) > 90)
//Alert the user to
alert ("Please enter an age between 16 and 90");

return false;

return valid;




This is the fields I would like them to enter into but when I do this in IE you can't click on the top 3 fields to enter data

<form name="rego_form" method="post" action=""
onSubmit="return validate_form ( );">

<h1>Please Fill Out Your Details Below</h1>

<p>Email: <input type="text" name="Email"></p>

<p>First Name: <input type="text" name="First_name"></p>

<p>Surame: <input type="text" name="Last_name"></p>

<p>Age: <input type="text" name="Age"></p>

<p>Address: <input type="text" name="Address"></p>

<p>City: <input type="text" name="City"></p>

<p>City: <input type="text" name="City"></p>

<p><input type="submit" name="send" value="Send Details"></p>


Any help would be greatly appreciated!

07-08-2011, 12:42 PM
Try onsubmit, no capital.

07-08-2011, 01:12 PM
I doubt the code works in IE. I doubt it could, can or will work in any browser, now or ever.


The method is document.getElementById('someidhere'), but anyway, your form element has no id. It has a name, which is not the same thing.

Replace all over