Why do I get this error? Javascript

// Add your JavaScript below!
var userFname = document.getElementsByName("fname").value;
var userLname = document.getElementsByName("lname").value;
var userAge = document.getElementsByName("age").value;
var patt = /a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*/;
var result = patt.test();

var validate_age = function(){
    if(isNaN(userAge)){
        alert("It looks like you didn't enter a number.")
    } else {alert ("You are " +userAge+ " old, right?")}
};

document.getElementById("submit_bttn").addEventListener("click", validate_age);

So i get this error: Uncaught TypeError: Cannot read property ‘addEventListener’ of null;
the HTML looks like this:

<!DOCTYPE html>
<html>
    <head>
		<title></title>
        <link/>
        <script type='text/javascript' src='script.js'></script>
	</head>
	<body>
        <!--Add your own HTML!--> 
        <form>
        First Name:<br>
        <input type="text"; name="fname"><br><br>
        Last Name:<br>
        <input type="text"; name="lname"><br><br>
        Age: <br>
        <input type="text"; name="age"><br><br>
        <input type="submit"; value="Submit"; id="submit_bttn">
        </form>
	</body>
</html>

Please help!

Semi-colons are invalid token in HTML element. Use space separator between attributes.

This topic was automatically closed after 7 days. New replies are no longer allowed.