i have a text box that’s required. when user clicks the submit button, the validation fires and prevents the form from submitting if there’s no value entered. I want the error message to go away after the user types a value in the text box so that the user knows the value entered is valid. Right now, the validation error message stays visible after the user makes a change. I’m using jquery-validation.
Share
You can set a flag for a
submitevent handler to check:Notice I used the
keyupevent since thevalueof the element will have changed by that point.Here is a demo: http://jsfiddle.net/jasper/NawBk/
Note that
.on()is new as of jQuery 1.7 and is the same in this case as.bind(): http://api.jquery.com/onAnd yeah, I just realized you’re using the jQuery Validate plugin, I’ll go ahead and leave this post because I think it can still help people.