views:

821

answers:

4

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?

+1  A: 

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

I would recommend change or keypress or keydown.

Clyde
+3  A: 

You can use $.keyup

Geoff
Ahh thanks, I am not sure how I missed it :)
Meep3D
+1  A: 

Since your using jQuery you should look into the jQuery Validation Plugin. It will take care of the events for you. :)

MitMaro
+1  A: 

I hope this plugin helps

http://www.geektantra.com/2009/09/jquery-live-form-validation/

GeekTantra