未为表单输入字段设置名称字段 [英] Name field not set for form input fields

查看:86
本文介绍了未为表单输入字段设置名称字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,它包含多个输入字段.如果我没有为每个字段提供ID或名称该怎么办.该字段将使用默认名称提交还是完全不提交.

I have a form and it contains multiple input fields. What if i don't provide an id or name to each and every field. will that field be submitted with some default name or won't be submitted at all.

这只是一个查询.不涉及任何代码. 谢谢

This is just a query. No code involved. Thanks

推荐答案

没有名称的表单控件不能成为成功的控件,也不会被提交.

Form controls without names cannot be successful controls and will not be submitted.

没有名称的控件的值将不包含在提交的表单数据中.

The value of a control without a name will not be included in the submitted form data.

请参见 HTML 4 :

See HTML 4:

成功提交的控件对提交是有效的".每个成功的控件都将其控件名称和其当前值配对,作为提交的表单数据集的一部分.成功的控件必须在FORM元素内定义,并且必须具有控件名称.

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.

HTML 5 :

如果满足以下任何条件,请跳过此元素的这些子步骤…字段元素不是其类型属性处于图像按钮"状态的输入元素,并且该字段元素都未指定名称属性,或者其名称属性的值为空字符串.

If any of the following conditions are met, then skip these substeps for this element … The field element is not an input element whose type attribute is in the Image Button state, and either the field element does not have a name attribute specified, or its name attribute's value is the empty string.


id与控件的成功无关.在那里只有名字很重要.


The id is irrelevant to the success of a control. Only the name matters there.

包含id仍然很重要,因为它是将<label>元素与控件关联的最佳方法(并且通过JS和CSS具有其他用途).

The id is still important to include as it is the best way to associate a <label> element with a control (and has other uses via JS and CSS).

这篇关于未为表单输入字段设置名称字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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