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:
<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:
<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:
<form>
<input name="test1">
<input name="test2">
<input type="button">
</form>
Līdzīgi darbosies tags button:
<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:
<form>
<input name="test1">
<input name="test2">
<input type="reset">
<input type="submit">
</form>
Izlabojiet šādu kodu tā, lai poga iesniegtu formu uz serveri:
<form>
<input name="name">
<input name="surn">
<button>send</button>
</form>