As I am beginner in HTML, could someone make a logical explanation on the following? I can submit data using <button type="submit">
, but if I had a single <form type="text">
, I could submit it just by pressing enter
.
As I failed to gather any info on that, does someone know how does it happen? Wouldn't it make sense to always have a button that would submit, and not also waiting for the user's enter? It feels as if enter on keyboard is same as button submit. Example:
<form action="https://www.youtube.com/results">
<input type="text" name="search_query">
<button>Submit me!</button>
</form>
This one also works by pressing just enter:
<form action="https://www.youtube.com/results">
<input type="text" name="search_query">
</form>
P.S. Of course on both these input types we have to type dog.