Tlačítka formuláře v JavaScriptu

Už víte, že formulář se odešle stisknutím tlačítka. Jsou zde však nuance. Tlačítko musí mít atribut type s hodnotou submit:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <input type="submit">
</form>

Formulář také odešle tag button s atributem type s hodnotou submit:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <button type="submit">btn</button>
</form>

Formulář bude také odeslán, pokud do libovolného vstupního pole umístíte fokus a stisknete Enter.

Tlačítko s atributem type s hodnotou button se používá jako prvek stránky a neodešle formulář:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <input type="button">
</form>

Stejným způsobem bude fungovat tag button:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <button>btn</button>
</form>

Tlačítko s atributem type s hodnotou reset vyčistí vyplněný formulář:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <input type="reset">
  <input type="submit">
</form>
Задание 1

Opravte následující kód tak, aby tlačítko odeslalo formulář na server:

html<form>
  <input name="name">
  <input name="surn">
  <button>send</button>
</form>