Coder Perfect

Form fields that have been disabled are not sending data [duplicate].


Is there a method to enable form fields that are disabled to submit data (through an attribute flag or something similar)?

Is there any way to prevent fields from being edited with CSS or any other property other than disabled without concealing them?

At the present, my special case is an identifier for a data-set that should be shown in the form (uneditable) – if there isn’t a better solution, I’m thinking of using a hidden field in addition to the disabled one to contain the real value, with the disabled one showing it.

Asked by bardiir

Solution #1

READONLY does not work for input type=’checkbox’> and select>…/select>, as previously stated.

If you have a Form with disabled checkboxes / selects AND need them to be submitted, you can use jQuery:

$('form').submit(function(e) {
    $(':disabled').each(function(e) {

On submission, this code removes the disabled attribute from all components.

Answered by Mario Werner

Solution #2

On fields you want to “disable” (perhaps with a greyed background), use CSS pointer-events:none to allow the POST action, such as:

<input type="text" class="disable">



Answered by Tom

Solution #3

The readonly only attribute can also be used with the following attributes –

readonly onclick=’return false;’

This is due to the fact that if we merely use readonly, the radio buttons will be changeable. We can use readonly with the above combination to avoid this problem. The editing will be restricted, and the values of the elements will be provided together with the form submission.

Answered by Kripa Yadav

Solution #4

Add CSS or a class to the input element that works in select and text tags, such as

style=”pointer-events: none;background-color:#E9ECEF”

Answered by Paresh

Post is based on