numegil numegil - 2 years ago 113
HTML Question

Making a text input field look disabled, but act readonly

I have an HTML input field that I want the user to be able to see, but not edit. If I mark the field as 'disabled', it doesn't get submitted along with the rest of the form. If I mark it as 'readonly', it behaves like what I want, but still looks enabled (at least on Chrome).

Basically, I want the input field to look like a disabled field, but behave as a readonly field. Is this possible?


edit: Also, if I mark it as 'readonly', it's still possible to change its value by double clicking it, and selecting something that was previously there.

Answer Source

Here is workaround: You have input disabled where you want ( just for displaying value ) and have a hidden input with name and value you need.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download