I have an html form like this:
<form name="f1">
<center>
<strong>Search VMs:</strong>
<input id='vms' name="word" type="text" size="50" placeholder="Name or IP, space delimited, partial name OK." autofocus autocomplete="off" pattern=".{3,}" required title="3 chars minimum" /> in
<select name="vc" id='whichvc'>
<option value="all" selected="selected">all VCs</option>
</select>
<input type="checkbox" id="check4detail" name="detail">Include details
<input name='searchbutton' value="Search VMs" type="button" onclick='xmlhttpPost("/cgi-bin/search-vm.pl")' />
<input value="Clear" type="button" onclick="clearBox('result')" />
</center>
</p>
<div id="loading"></div>
<div id="result"></div>
</form>
As you can see, there are a text input field and a few other buttons, one of which has a onclick() listener associated to it. How do I trigger the onclick event on that button when user enters text and press enter?
Tried this solution from the forum but it somehow does not work:
$('#vms').keypress(function(event){
if (event.which === 13){
$('#searchbutton').click();}
});
BTW, when I enter a text in the field and click on the search button, it work just fine. But enter text and press enter does not trigger a search event somehow.