Glen Gibb
asked on
jquery - if ( keyCode == 13) allows all key values
Experts,
I'm trying to submit a form when the enter key is pressed. This code executes when ANY key is pressed!
function onKeyUp(e) {
if ( e.keyCode == 13)
$(this).closest('form').su bmit();
}
I've also tried "code = (e.keyCode) ? e.keyCode : e.which;" to set the value. The keyCode value is fine.
But e.keyCode == 77 slips right through the filter!
Any ideas?
I'm trying to submit a form when the enter key is pressed. This code executes when ANY key is pressed!
function onKeyUp(e) {
if ( e.keyCode == 13)
$(this).closest('form').su
}
I've also tried "code = (e.keyCode) ? e.keyCode : e.which;" to set the value. The keyCode value is fine.
But e.keyCode == 77 slips right through the filter!
Any ideas?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER