开发者

jQuery Validator -- only validate onblur event (not onchange)

开发者 https://www.devze.com 2023-03-18 19:31 出处:网络
I\'m using the jQuery validator and would like to validate certain elements when certain events occ开发者_开发问答ur.

I'm using the jQuery validator and would like to validate certain elements when certain events occ开发者_开发问答ur.

For example: some textboxes should only validate onblur, whereas some should validate on key change.

I'd like to declare this somehow here.. and how can i do this so the event is specific to the element?

Something like this:

$("#form").validate({
       someevent:true,
       rules{
          textbox1:required,
          textbox2:{
              required:true,
              event:onblur // only do onblur
       }
    });

How can I acheive this?


Like this:

  $('form').validate({
    onfocusout: function(e) {
      this.element(e);
    }
    , onkeyup: false
  });


Maybe something like this?

$("#element").blur(function(){
   $(this).validate({
      // your code here
   })
})
0

精彩评论

暂无评论...
验证码 换一张
取 消