Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem getting form to work in FF

    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.

    Code:
    <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;
    
    }
    
    //-->
    
    </script>
    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
    Code:
    <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>
    
    </form>
    Any help would be greatly appreciated!

  • #2
    Regular Coder
    Join Date
    May 2010
    Location
    Bathurst, Australia
    Posts
    180
    Thanks
    1
    Thanked 22 Times in 22 Posts
    Try onsubmit, no capital.
    Disclaimer: I'm hungover 70% of the time i'm on here, any information given may not be correct, or even legible.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I doubt the code works in IE. I doubt it could, can or will work in any browser, now or ever.
    Code:
    document.getElementById.rego_form.First_name.value
    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
    Code:
    document.getElementById.rego_form
    with:
    Code:
    document.forms['rego_form']
    Last edited by Kor; 07-08-2011 at 01:14 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •