gruber
gruber

Reputation: 29727

enter in textBox

Im trying to create functionality in which after user enters "ENTER" button the button is clicked.

What I came to is :

$(selector).keyup(function(e) {
    if (e.keyCode == 13) {
        eval($("#" + buttonID).attr('href'));
    }
});

it works perfectly but there is one example in which i would like it to behave in different way:

When I start typing letters in my textBox there are hints displayed below (stanard chrome behaviour) so that I can choose one of the previous values typed to the textBox. I choose it and hit enter. At this point I dont want to submit form but it does according to my js code. Is there any way to get rid of such behaviour ?

thanks for help

Upvotes: 0

Views: 955

Answers (1)

gruber
gruber

Reputation: 29727

Problem resolved by using keypress event.

Upvotes: 1

Related Questions