How can I get the form value from a disabled <input> element

后端 未结 10 1445
小鲜肉
小鲜肉 2020-12-04 23:50

The HTML standard for forms appears to be such that disabled input elements do not contribute to the form name/value collection.

Is there ANY way to get around this?

10条回答
  •  不思量自难忘°
    2020-12-05 00:14

    I whipped up a quick (Jquery only) plugin, that saves the value in a data field while an input is disabled. This just means as long as the field is being disabled programmaticly through jquery using .prop() or .attr()... then accessing the value by .val(), .serialize() or .serializeArra() will always return the value even if disabled :)

    https://github.com/Jezternz/jq-disabled-inputs

提交回复
热议问题