I have an HTML form that looks like this:
ar form={
formName: document.getElementById("contactus"),
name: document.getElementById("name"),
email: document.getElementById("email"),
comment: document.getElementById("question")
};
//form submit
form.formName.addEventListener( "submit", checkform );
<form name="contactus" method="post" action="html_form_send.php">
<label for="name">Name:</label><br /><input <input type="text" name="name" maxlength="50" size="59" autofocus required/><br /><br />
<label for="email">E-Mail Address:</label><br /><input type="email" name="email" maxlength="50" size="59" required/><br /><br />
<label for="question">Question:</label><br /><textarea name="question" maxlength="1000" cols="50" rows="6" required></textarea><br /><br />
<input class="c1_scButton" type="submit" value="send"/>
</form>
<script type="text/javascript" src="js/validate.js"></script>
The problem is that Firebug shows that form.formName
is null, as are the rest of the form values. Why are they not acquiring the elements?
The ultimate goal of the script is to validate the form data. I think the rest of the form will work if the elements will load.