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

后端 未结 10 1467
小鲜肉
小鲜肉 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:35

    I suppose this is a hack, but seems to work well for me. Do both! User sees disabled input, clearly ghosted and browser prevents interaction - but it is not submitted with form. The user doesn't see the potentially disorienting readonly field, yet it is submitted with the form.

    
    
    

提交回复
热议问题