I have some disabled inputs in my form and I want to send them to the server, but Chrome excludes them from the request.
Is there a way to solve this problem without adding hidden fields?
<form action="/Media/Add"> <input type="hidden" name="Id" value="123" /> <!-- this does not appear in request --> <input type="textbox" name="Percentage" value="100" disabled="disabled" /> </form>
P粉7224099962023-10-15 17:03:45
Use Jquery and send data using ajax, you can solve your problem:
<script> $('#form_id').submit(function() { $("#input_disabled_id").prop('disabled', false); //Rest of code }) </script>
P粉2983052662023-10-15 10:30:33
Elements with the disabled
attribute are not submitted, or you can say that their values are not posted (see HTML 5 Specification for Building Form Datasets).
Right now,
<input type="textbox" name="Percentage" value="100" disabled="disabled" />
FYI, as per 17.12.1 In the HTML 4 specification:
You can use the readonly
attribute in your case, by doing this you will be able to post the data of the field.
Right now,
<input type="textbox" name="Percentage" value="100" readonly="readonly" />
For reference only, according to 17.12.2 In the HTML 4 specification: