JavaScript validating form error message <p>I have been working on this form validation and I got the error message to work when I have it displaying as an alert but I cannot seem to get it to print out with <code>document.getElementById("").innerHTML =</code>.</p> <p>I also have this as the form </p> <pre><code> &lt;form id="form" name="form" method="post" onSubmit="return validate(this) &amp;&amp; reportErrors(errors)" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt; var ck_name = /^(Mr|Mrs)\. (.+)? (.+)?/i; var ck_street = /^[0-9]{2,3} +[a-z A-Z]+ +(Street|Road)$/; var ck_postalInput = /^([D-JL-Wd-jl-w]{2})([1-9]{1})[\-\s]?([D-JL-Wd- jl-w]{1})([1-9]{2})$/; var ck_phoneInput = /^[+]?([\d]{0,3})?[\(\.\-\s]?([\d]{3})[\)\.\-\s]* ([\d]{3})[\.\-\s]?([\d]{4})$/; var ck_emailInput =/^[a-zA-Z]+(.)+[a-zA-Z]+(@mohawkcollege)+(.com|.ca|.org)$/; function validate(form){ var nameInput = form.nameInput.value; var streetInput = form.streetInput.value; var postalInput = form.postalInput.value; var phoneInput = form.phoneInput.value; var emailInput = form.emailInput.value; var errors = []; if (!ck_name.test(nameInput)) { errors[errors.length] = "Full name not entered correctly."; } if (!ck_street.test(streetInput)) { errors[errors.length] = "Street name not entered correctly."; } if (!ck_postalInput.test(postalInput)) { errors[errors.length] = "Postal not entered correctly."; } if (!ck_phoneInput.test(phoneInput)) { errors[errors.length] = "Phone number not entered correctly."; } if (!ck_emailInput.test(emailInput)){ errors[errors.length] = "email not entered correctly."; } if (errors.length &gt; 0) { reportErrors(errors); return false; } return true; } function reportErrors(errors){ var msg = "Please Enter Valide Data...\n"; for (var i = 0; i&lt;errors.length; i++) { msg += "\n" + ". " + errors[i]; } document.getElementById("error").innerHtml=msg; } </code></pre>