Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to bind keyup to entire form?

Is it possible to bind keyup() to an entire <form>? For example, I have multiple <input type="text"> fields inside a form, and I want to bind a keyup event to all of them without having to attach a keyup event handler to each one. Rather, I want to bind one keyup event handler to all of them so if any of the text fields detect a keyup event, the event handler will run. Is this possible in jQuery?

I tried:

$('form').keyup(function() {...});

But that made the keyup event handler fire indefinitely after typing one character.

like image 351
George Newton Avatar asked Dec 26 '22 11:12

George Newton


1 Answers

I don't think this is possible, but you are able to bind the same keyup event to all the inputs at once:

$('#myform input[type=text]').on('keyup', /* yada */);
like image 108
TimWolla Avatar answered Feb 06 '23 08:02

TimWolla