Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing an HTML form field from being submitted

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?

like image 335
at. Avatar asked Oct 23 '25 23:10

at.


1 Answers

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

like image 186
VisioN Avatar answered Oct 26 '25 13:10

VisioN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!