andandandand
andandandand

Reputation: 22260

jquery validate: how can I make a field validate on change?

On jquery's validate plugin, an error message only disappears after the user has made focus on another element. I want to make it disappear as soon as the right info is written. How can validation be triggered 'onchange'?

Upvotes: 4

Views: 17057

Answers (2)

Nomad Monday
Nomad Monday

Reputation: 1

I came across this while looking into a similar problem. I believe the accepted answer is a little misleading. The validate() method is for initializing and setting up validation behavior, whereas the valid() method will actually run the validation check. So, in order to run a validation check on change, I ended up using something like this:

$(function() {
    $("#elementId").on("change", function() {
        $(this).valid();
    });
});

Upvotes: 0

Aaron Saunders
Aaron Saunders

Reputation: 33335

$(".selector").validate({
   onkeyup: true
})

Upvotes: 6

Related Questions