tags:

views:

408

answers:

1

Hi.

I´m trying this on Opera 10 and doesn´t work:

$('input').keydown(function(){ return false; });

This works fine in other browsers.

Can anybody tell me something about this??

Thanks!

+4  A: 

See the key events compatibility table. Opera does not cancel a keypress when keydown preventsDefault. Use the keypress event instead to cancel keyboard input.

(Although, this is rarely a good idea. Intercepting keypresses does not stop a field being changed by other means than keys, for example drag and drop. Set the readonly or disabled properties true to properly stop the value being changed.)

bobince
Thanks!!You are right. This is only an "ornament". I want the input only for integers values. Then, I check it on submit and in server side too.Thank you again!
Kete
Kete: you can use <input type="number"> per HTML5 if you want integers ;)However, I see Opera doesn't prevent alpha input - it just fails to submit it. We should do something more intelligent here.. :-p
hallvors