How can I use the function keypress to validate the input on Javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can I use the function keypress to validate the input on Javascript?

some examples please

12th Sep 2017, 7:33 PM
Abraham Mora
Abraham Mora - avatar
2 Answers
+ 10
I recommend to use "oninput", it's much more useful for validations! Here an example, try to use "onkeypress" (or "onkeydown", the first one does not work in my browser) and see the difference: https://code.sololearn.com/W4Ew7WdT86Hd/?ref=app
12th Sep 2017, 7:50 PM
Maz
Maz - avatar
+ 4
thank you :) very useful
12th Sep 2017, 10:27 PM
Abraham Mora
Abraham Mora - avatar