Sometimes, we want to submit a form when the return key is pressed with HTML.
In this article, we’ll look at how to submit a form when the return key is pressed with HTML.
How to submit a form when the return key is pressed with HTML?
To submit a form when the return key is pressed with HTML, we can add an input with type
attribute set to submit
.
For instance, we write
<form action="" method="get">
Name: <input type="text" name="name" /><br />
Pwd: <input type="password" name="password" /><br />
<div class="yourCustomDiv" />
<input type="submit" style="display: none" />
</form>
to add an input with type
set to submit
in our form.
Then when we press enter, a submission is made by the form.
Conclusion
To submit a form when the return key is pressed with HTML, we can add an input with type
attribute set to submit
.