samedi 28 février 2015

HTML: control form submission by pressing enter from text input [duplicate]


This question already has an answer here:




I have noticed that when I am with my cursor in a text input and I press enter the form will submit.



<!DOCTYPE html>
<html>
<body>

<form action="action_page.php">

<input type="radio" name="sex" value="male">Male<br>
<input type="radio" name="sex" value="female">Female<br>

First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>

<p>If you click "Submit", the form-data will be sent to a page called "action_page.php".</p>

</body>
</html>


I found that slightly confusing for the user, because a hit on enter from within a text input could simply notify "I am done with this input". How do I control (prevent) that?


Aucun commentaire:

Enregistrer un commentaire