HTML5表单元素禁用,带有必需和禁用元素的Html5表单验证

我意识到你永远不应该禁用一个元素并且也需要它,因为如果它被禁用,用户怎么能使它有效?

但是,我有一个< select>我希望用户可以选择的产品.当他们选择其中一个产品时,另一个< select>仅当产品具有一个或多个型号时,才会填充,启用和要求产品型号.否则,禁用并清空模型选择.

虽然我喜欢认为我的代码是完美的,但我可以做到这样,模型下拉列表永远不会被禁用并且同时需要,我并不完美.那么,表格是否能够通过< select>提交.那是禁用和必需的?

更新

来自w3.org:

Constraint validation: If the element is required,and its value IDL attribute applies and is in the mode value,and the element is mutable,and the element’s value is the empty string,then the element is suffering from being missing.

查看具体的“可变”意味着什么.

A form control can be designated as mutable.

Note: This determines (by means of definitions and requirements in this specification that rely on whether an element is so designated) whether or not the user can modify the value or checkedness of a form control,or whether or not a control can be automatically prefilled.

选择没有值,因此它由它的选项决定.

The select element does not have a value; the selectedness of its option elements is what is used instead.

所以,我认为这意味着如果< select>元素被禁用和要求,表格可以被视为有效吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值