How can I submit a pure inputs value using the enter key? I only have an input field like this and nothing more. The idea is to submit the value in it using ajax when a user hits enter.
<input class="input-xxlarge search" type="search" name="search" value="" autocomplete="off" placeholder="Search for recipes">
$('.search').submit(function(event){
console.log('Ok');
var $this = $(this);
var query = $this.('.search').val();
if(query.length >= 2 || query.lenght <=24) {
console.log(query);
} else {
// Do not submit the form
event.preventDefault();
}
});
I'm having problems getting the thing to submit on enter and getting it's value. Can you please help?