jquery newbie: combine validate with hidding submit button

前端 未结 3 657
傲寒
傲寒 2021-01-07 09:48

I\'m new a jQuery. I have gotten validate to work with my form (MVC 1.0 / C#) with this:

      

        
3条回答
  •  孤城傲影
    2021-01-07 10:25

    If you're using this validation plugin, it comes with a valid() method.

      jQuery('input[type=submit]').click(function() {
          var self = $(this);
    
          if (self.data('clicked')) {
              return false;
          } else if (self.closest('form').valid()) {
              self.data('clicked', true);
    
              return true;
          };
      });
    

    or even:

      jQuery('input[type=submit]').click(function(event) {
          var self = $(this);   
    
          if (self.closest('form').valid()) {
              self.attr('disabled', true);
          };
      });
    

提交回复
热议问题