Reputation: 9
I have this HTML code
<form method="post" action="adminstudent.php" enctype="form-data/multipart">
<input type="text" id="searchStudent" class="form-control" name="txtsearch" placeholder="Search Student...">
<input type="submit" name="btnsearch" value="Search" class="btn btn-warning">
</form>
and JQUERY to trigger if ENTER KEY is pressed
$('#searchStudent').keypress(function(event){
if (event.keyCode == 13) {
$('#btnsearch').click();
}
});
But it just refresh when I pressed Enter Key.
Upvotes: 0
Views: 1029
Reputation: 5849
Why would you want to develop a feature that is already implemented in all browsers since ages?
Just drop the jQuery altogether and leave the form as such. As long as you have have a <form>
tag enclosing an <input type="submit" value="Send"/>
(or <button type="submit">Send</button>
), pressing the Enter
key in any of the inputs
will submit the form.
Upvotes: 1