dimanche 12 avril 2015

Input field not submitting on enter press

I have a problem with submitting a input field. I know I am not the first one who ask this question but I looked at the answers and they didn't work.


I have an input field and a submit button inside a div. I have the code working so that you can search on button press but I can't get submitting on enter press working.


html:



<div class="search singers" action="templates/search/search_singer.php" method="POST">
<input name="search" type="text" id="search" placeholder="Search here for singers" onkeyup="autosug();" data-file="search_singers"/><input class="button" type="submit" value="Search" onclick="search();"/>
<div id="output" class="output">

</div>
</div>


Jquery code:



var link = '#search';

//post input
$(function(){
$(link).keydown(function(e){
if (e.keyCode == 13) {
$(link).submit();
//He detect an enter press but stops then
}
});
});


I found the Jquery code on this site

And here a similar question: here


Aucun commentaire:

Enregistrer un commentaire