Preventing an HTML form field from being submitted

css, html, javascript

Solution

Simply set `disabled` attribute for the form field, e.g.

<input name="test" value="test" disabled="disabled">

REF: http://www.w3.org/TR/html401/interact/forms.html#h-17.12.1

Problem

I want to programmatically allow or hide a form field from being submitted in an HTML5 form. I thought I could just set its CSS `display` attribute to `none`. However, it still gets submitted (just can't be seen). Is there another property I can set rather than removing the element completely from the HTML5 document?

Original source