Disabled form fields not submitting data

Is there any way (with a attribute flag or something like that) to enable form fields that are disabled to submit data?

Or, if that's not possible, is there any way to block fields from editing with css or any other attribute than disabled without hiding them?

My special case at the moment is an identifier for a data-set that should be shown in the form (uneditable) - if there is no better solution I think i'll use a hidden field in addition to the disabled one to hold the actual value with the disabled one showing it.


检出readonly属性http://www.w3schools.com/tags/att_input_readonly.asp


Elements with Disabled attribute are not submitted or you can say their values are not posted.

ie

<input type="textbox" name="Percentage" value="100" disabled="disabled" /> 

FYI,

  • Disabled controls do not receive focus.
  • Disabled controls are skipped in tabbing navigation.
  • Disabled controls cannot be successfully posted.
  • You can use readonly attribute in your case, by doing this you will be able to post your field's data.

    ie

    <input type="textbox" name="Percentage" value="100" readonly="readonly" />
    

    FYI,

  • Read-only elements receive focus but cannot be modified by the user.
  • Read-only elements are included in tabbing navigation.
  • Read-only elements are successfully posted.
  • Note: READONLY doesn't work on checkboxes and select tags

    Ref from


    As it was already mentioned: READONLY does not work for <input type='checkbox'> and <select>...</select> .

    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) {
            $(this).removeAttr('disabled');
        })
    });
    

    This code removes the disabled attribute from all elements on submit.

    链接地址: http://www.djcxy.com/p/26466.html

    上一篇: JRE7上的JNDI命名异常

    下一篇: 禁用表单字段不提交数据