Everyone of us sometime or other had to restrict the user from entering non-numeric values in to a text field. We normally validate user input when user presses the submit button or when the user leave the input field and display the error message in a span or using alert() javascript function.
However what will happen if we validate user input as the user is typing in the field and also use a alert box to display error message instead of showing it in a span?
Please do not do this ever and annoy your dear visitors and make them ask "who developed this crap?".
In the recent past, I had to fill out a form where I was supposed to enter my phone number and they ware using this annoying technique. Now I mistyped my number and the validation script throws an alert(). I press "OK" by pressing space bar and to silence my screen reader, I pressed "ctrl". You can guess the result. The alert comes again!
So, we developers should never try to annoy our users using this kind of unnecessary tricks, instead we should make our user interfaces as smooth as possible to use for both normal users and users with special needs.
Never try to outsmart your visitors because situation will outsmart us! And never try to lock the user's keyboard because it's their keyboard and they are free to use it as they like.