How to avoid sending input fields which are hidden by display:none to a server?

后端 未结 6 1445
野性不改
野性不改 2020-11-28 10:19

Imagine you have a form where you switch visibility of several fields. And if the field is not displayed you don\'t want its value to be in request.

How do you handl

6条回答
  •  孤街浪徒
    2020-11-28 10:50

    If you wanna disable all elements or certain elements within a hidden parent element, you can use

    $("div").filter(":hidden").children("input[type='text']").attr("disabled", "disabled");
    

    This example http://jsfiddle.net/gKsTS/ disables all textboxes within a hidden div

提交回复
热议问题