Formas pogas JavaScript

Jūs jau zināt, ka forma tiek iesniegta, nospiežot uz pogas. Tomēr šeit ir nianses. Pogai obligāti jābūt atribūtam type ar vērtību submit:

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

Formu iesniegs arī tags button ar atribūtu type ar vērtību submit:

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

Forma tiks iesniegta arī tad, ja jebkurā inputā iestatīsiet fokusu un nospiedīsiet Enter.

Poga ar atribūtu type ar vērtību button tiek izmantota kā lapas elements un neiesniegs formu:

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

Līdzīgi darbosies tags button:

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

Poga ar atribūtu type ar vērtību reset notīrīs aizpildīto formu:

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

Izlabojiet šādu kodu tā, lai poga iesniegtu formu uz serveri:

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