For TEXTAREA, how to call a JavaScript function on return / input
3 answers
If you are using jQuery you can do this:
$('#myTextarea').keydown(function(e) {
if(e.which == 13) {
// Enter was pressed. Run your code.
}
});
The handler keypress
runs on every key press and checks the 'enter' key.
EDIT:
Changed keypress
to keydown
as it keypress
can run code multiple times if the user holds Enter
. Probably not what you need.
+2
a source to share