Disabled form inputs do not appear in the request

后端 未结 11 2008
暗喜
暗喜 2020-11-22 04:37

I have some disabled inputs in a form and I want to send them to a server, but Chrome excludes them from the request.

Is there any workaround for this without addin

11条回答
  •  独厮守ぢ
    2020-11-22 05:08

    Elements with the disabled attribute are not submitted or you can say their values are not posted (see the second bullet point under Step 3 in the HTML 5 spec for building the form data set).

    I.e.,

     
    

    FYI, per 17.12.1 in the HTML 4 spec:

    1. Disabled controls do not receive focus.
    2. Disabled controls are skipped in tabbing navigation.
    3. 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.

    I.e.,

    
    

    FYI, per 17.12.2 in the HTML 4 spec:

    1. Read-only elements receive focus but cannot be modified by the user.
    2. Read-only elements are included in tabbing navigation.
    3. Read-only elements are successfully posted.

提交回复
热议问题