将不会提交禁用输入的值 [英] Values of disabled inputs will not be submitted

查看:19
本文介绍了将不会提交禁用输入的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在 Firefox 中通过 Firebug 发现的.

其他浏览器也一样吗?

如果是,原因是什么?

解决方案

是的,所有浏览器不应提交禁用的输入,因为它们是只读的.

更多信息(第 17.12.1 节)<块引用>

属性定义

disabled [CI] 当为表单控件设置时,这个布尔属性禁用对用户输入的控制.设置后,禁用属性对元素有以下影响:

  • 禁用的控件不会获得焦点.
  • 在标签导航中跳过禁用的控件.
  • 禁用的控件无法成功.

以下元素支持禁用属性:BUTTON、INPUT、OPTGROUP、OPTION、SELECT 和 TEXTAREA.

此属性是继承的,但本地声明覆盖了继承的价值.

禁用元素的呈现方式取决于用户代理.为了例如,一些用户代理变灰"禁用菜单项,按钮标签等

在本例中,INPUT 元素被禁用.因此,它不能接收用户输入也不会随表单提交其值.

注意.动态修改disabled值的唯一方法属性是通过脚本实现的.

This is what I found by Firebug in Firefox.

Is it the same in other browsers?

If so, what's the reason for this?

解决方案

Yes, all browsers should not submit the disabled inputs, as they are read-only.

More information (section 17.12.1)

Attribute definitions

disabled [CI] When set for a form control, this Boolean attribute disables the control for user input. When set, the disabled attribute has the following effects on an element:

  • Disabled controls do not receive focus.
  • Disabled controls are skipped in tabbing navigation.
  • Disabled controls cannot be successful.

The following elements support the disabled attribute: BUTTON, INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA.

This attribute is inherited but local declarations override the inherited value.

How disabled elements are rendered depends on the user agent. For example, some user agents "gray out" disabled menu items, button labels, etc.

In this example, the INPUT element is disabled. Therefore, it cannot receive user input nor will its value be submitted with the form.

<INPUT disabled name="fred" value="stone">

Note. The only way to modify dynamically the value of the disabled attribute is through a script.

这篇关于将不会提交禁用输入的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆