Reputation: 292
Right now I have a form with one input and one textarea, and I am trying to add an input, however when I do it causes the form to not submit, I am submitting by hitting the enter key and not using a button.
Current code:
<form method="POST">
Suggestion Subject: <input class="login-input" name="subject"><br>
Suggestion:
<textarea class="login-input" rows="8" name="suggestion"></textarea><br>
Username:
<input class="login-input" type="text" name="name"><br>
Hit the Enter key to submit your suggestion
</form>
When I add the Suggestion Subject
input, it can no longer be submitted.
Any idea why?
Upvotes: 0
Views: 136
Reputation: 2865
Add type="text" to your subject field, like so:
<input class="login-input" type="text" name="subject">
and add a submit button like so (this will hide in all browsers):
<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
Upvotes: 0
Reputation: 207901
The default behavior of a HTML form with a single input field is to submit the form on pressing enter on that field. Once you add more text inputs, pressing enter will no longer submit the form. To submit the form via enter, you'll need to add a submit button. If you don't want to see the button you can hide it.
Upvotes: 2