Atributo de formulário HTML <button>
Exemplo
Um botão localizado fora de um formulário (mas ainda faz parte do formulário):
<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>
Definição e uso
O form
atributo especifica o formulário ao qual o botão pertence.
O valor deste atributo deve ser igual ao id
atributo de um
<form>
elemento no mesmo documento.
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que suporta totalmente o atributo.
Attribute | |||||
---|---|---|---|---|---|
form | 10.0 | 16.0 | 4.0 | 5.1 | 9.5 |
Sintaxe
<button form="form_id">
Valores de atributo
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. |
❮ Tag HTML <button>