HTMLFieldSetElement

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

HTML Field Set Element

DOM fieldset elements expose the HTMLFieldSetElement (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.

属性

属性继承自其父级 HTMLElement

名称 类型 描述
disabled Boolean 读取 HTML 属性 disabled,表明用户是否可以操作该控件。
elements readonly HTMLFormControlsCollection The elements belonging to this field set.
form 只读 An HTMLFormControlsCollection or HTMLCollection referencing the containing form element, if this element is in a form. If the field set is not a descendant of a form element, then the attribute can be the ID of any form element in the same document it is related to, or the null value if none matches.
name DOMString Reflects the name 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 设置一个自定义错误,则该元素将无法通过有效性验证。参数指定的字符串就是在向用户报告错误时显示的消息。如果为空字符串,则清除这个自定义错误。