Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery realtime form validation

I am currently using $.blur(fn();) for form validation, but this only takes effect when the form field loses focus. Is there a way of doing it on keypress to get realtime validation? I suppose I could do the 'poll all fields every second' approach, but I am sure there must be a more elegant way?

like image 730
Meep3D Avatar asked Nov 21 '25 09:11

Meep3D


2 Answers

You can use $.keyup

like image 130
Geoff Avatar answered Nov 23 '25 23:11

Geoff


There are lots of other events you could use. See here: http://docs.jquery.com/Events

I would recommend change or keypress or keydown.

like image 37
Clyde Avatar answered Nov 23 '25 22:11

Clyde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!