Thuộc tính biểu mẫu HTML <button>

❮ Thẻ HTML <button>

Thí dụ

Một nút nằm bên ngoài biểu mẫu (nhưng vẫn là một phần của biểu mẫu):

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

Định nghĩa và Cách sử dụng

Thuộc formtính chỉ định hình thức mà nút thuộc về.

Giá trị của thuộc tính này phải bằng idthuộc tính của một <form> phần tử trong cùng một tài liệu.


Hỗ trợ trình duyệt

Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.

Attribute
form 10.0 16.0 4.0 5.1 9.5

Cú pháp

<button form="form_id">

Giá trị thuộc tính

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.

❮ Thẻ HTML <button>