Validation on a Keydown (or) Keypress

And what’s the problem with the methods you tried to use?