/
index.md
32 lines (24 loc) · 7.7 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
title: HTMLFieldSetElement
slug: Web/API/HTMLFieldSetElement
---
{{ ApiRef() }}
## HTML Field Set Element
DOM `fieldset` elements expose the [HTMLFieldSetElement](http://dev.w3.org/html5/spec/forms.html#htmlfieldsetelement) ([HTMLFieldSetElement](https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7365882)) interface, which provides special properties and methods (beyond the regular [element](/zh-CN/docs/Web/API/element) object interface they also have available to them by inheritance) for manipulating the layout and presentation of field-set elements.
## 属性
属性继承自其父级 {{domxref("HTMLElement")}}。
| 名称 | 类型 | 描述 |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `disabled` | `Boolean` | 读取 HTML 属性 [`disabled`](/zh-CN/docs/Web/HTML/Element/fieldset#disabled),表明用户是否可以操作该控件。 |
| `elements` | `readonly HTMLFormControlsCollection` | The elements belonging to this field set. |
| `form` {{ReadOnlyInline}} | An {{domxref("HTMLFormControlsCollection")}} or {{domxref("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`](/zh-CN/DOM/DOMString) | Reflects the [`name`](/zh-CN/docs/Web/HTML/Element/fieldset#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](/zh-CN/DOM/DOMString) `error)` | `void` | 设置一个自定义错误,则该元素将无法通过有效性验证。参数指定的字符串就是在向用户报告错误时显示的消息。如果为空字符串,则清除这个自定义错误。 |