gpt4 book ai didi

jquery - 使用 jQuery 忽略表单提交上的输入字段

转载 作者:行者123 更新时间:2023-12-03 22:56:39 24 4
gpt4 key购买 nike

我想在使用 jQuery 提交表单时仅包含某些表单字段。例如,我想忽略所有具有 disabled 属性的字段...也许是这样的:

$('#my_button').click(function() {
if($('input').hasAttr('disabled') {
//ignore this form field when submitting
}
$('form').submit();
});

有什么想法吗?

最佳答案

没必要,disabled输入已经被排除。各种 jQuery 方法,包括 submit()serialize() 均遵循 HTML 4 规范来禁用 Web 表单中的控件,具体如下:

A successful control is "valid" for submission. Every successful control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a FORM element and must have a control name.

However:

  • Controls that are disabled cannot be successful.

http://www.w3.org/TR/html401/interact/forms.html#successful-controls

关于jquery - 使用 jQuery 忽略表单提交上的输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4119238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com