jQuery Validation PlugIn : Callback for field success validation?

后端 未结 2 1198
广开言路
广开言路 2021-01-15 13:26

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

Is there a way to u

相关标签:
2条回答
  • 2021-01-15 13:31

    You might want to check out the success option.

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

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

    If you pass a function to success, you are given back the label as a jQuery object. You can then manipulate that object or a related object.


    Alternatively, your error and success graphic can use a background image, and then you can swap out the background image with CSS on the validClass.

    0 讨论(0)
  • 2021-01-15 13:45

    You can override the defaults validClass: "valid" with validClass:"success"

    0 讨论(0)
提交回复
热议问题