且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

未为表单输入字段设置名称字段

更新时间:2023-02-25 12:20:44

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

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).