JQuery Validation PlugIn: Callback to verify field success?

I use errorPlacement to add a class to the label to show a graphic element in addition to the error text (they are both different elements).

Is there a way to use a callback that will fire when a field validates successfully? I am already using validClass, which will change the error message, but I need to call back to change the graphic to “successful”.

Example

[picture] [input field] [error text]

I was able to change [picture] and [error text] when there is an error, but when the correct value is entered in the field, I was able to change [error text], but not [graphic].

+2
source share
2 answers

, success.

http://docs.jquery.com/Plugins/Validation/validate#options

$("#myform").validate({
   success: function(label) {
     label.addClass("valid").text("Ok!")
   },
   submitHandler: function() { alert("Submitted!") }
})

success, jQuery. .


, , CSS validClass.

+2

validClass: "valid" validClass: "success"

0

All Articles