So I had an assignment due last night that was meant to practice some basic HTML layout stuff using forms and posting to a test ASP page that just spits back all the elements on the page and their attributes.

Where I ran into trouble was validating the form before submitting it. Four of the fields are required to not be blank, and one of which, the Postal Code, also requires special validation for the format of the postal code itself. What I tried to do was make all the necessary fields required using the "required" attribute from HTML5.

The first issue I ran into was using a normal button to manually submit the form after checking the postal code format. Apparently, form.submit() does not actually check for the "required" attribute; you have to actually use a Submit input. So then I tried to use the onsubmit attribute of the form to call my validation function. I'm pretty sure at one point this did work, but something broke and the form gets submitted regardless of whether or not the postal code entered actually fits the regex I'm using to validate the format. I have no idea why this is, and this is what I was hoping to get some help/clarification on.

I put the entire page on pastebin if anyone feels like taking a look. As long as none of the text boxes are empty, the form gets submitted even though it shouldn't if the postal code isn't formatted correctly.

Anyone have any ideas?