--- title: HTMLFieldSetElement slug: Web/API/HTMLFieldSetElement translation_of: Web/API/HTMLFieldSetElement ---

{{ ApiRef() }}

HTML Field Set Element

DOM fieldset elements expose the HTMLFieldSetElement  ({{ HTMLVersionInline(4) }} HTMLFieldSetElement) interface, which provides special properties and methods (beyond the regular element object interface they also have available to them by inheritance) for manipulating the layout and presentation of field-set elements.

属性

以下属性除了 form 都是在 {{ HTMLVersionInline(5) }} 中新添加的.

名称 类型 描述
disabled Boolean 读取HTML属性 {{ htmlattrxref("disabled", "fieldset") }},表明用户是否可以操作该控件.
elements readonly HTMLFormControlsCollection The elements belonging to this field set.
form readonly HTMLFormElement The containing form element, if this element is in a form. Otherwise, the element the name content attribute points to {{ HTMLVersionInline(5) }}. (null in {{ HTMLVersionInline(4) }}.)
name DOMString Reflects the {{ htmlattrxref("name", "fieldset") }} HTML attribute, containing the name of the field set, used for submitting the form.
type readonly DOMString 一定为字符串fieldset.
validationMessage readonly DOMString A localized message that describes the validation constraints that the element does not satisfy (if any). This is the empty string if the element  is not a candidate for constraint validation (willValidate is false), or it satisfies its constraints.
validity readonly ValidityState The validity states that this element is in.
willValidate boolean Always false because fieldset objects are never candidates for constraint validation.

方法

名称 & 参数 返回值 描述
checkValidity() Boolean 如果元素的值没有有效性问题,则返回true,否则返回false并触发invalid事件.
setCustomValidity(in DOMString error) void 设置一个自定义错误,则该元素将无法通过有效性验证.参数指定的字符串就是在向用户报告错误时显示的消息.如果为空字符串,则清除这个自定义错误.