HTML <ボタン>フォーム属性
例
フォームの外側にあるボタン(ただし、フォームの一部):
<form action="/action_page.php" method="get" id="form1">
<label for="fname">First
name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname"
name="lname">
</form>
<button type="submit" form="form1"
value="Submit">Submit</button>
定義と使用法
このform
属性は、ボタンが属するフォームを指定します。
この属性の値は
、同じドキュメント内の要素のid
属性と同じである必要があります。
<form>
ブラウザのサポート
表の数字は、属性を完全にサポートする最初のブラウザーバージョンを示しています。
Attribute | |||||
---|---|---|---|---|---|
form | 10.0 | 16.0 | 4.0 | 5.1 | 9.5 |
構文
<button form="form_id">
属性値
Value | Description |
---|---|
form_id | Specifies the form element the <button> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document. |
❮HTML<button>タグ