title: jQuery validation not working when using ASP.NET button
body: <p>I use jQuery for form validation. When the user doesn't fill out the form he get the message "some fields required".  This works if I have a input button, but when I change this to asp:button to postback the webpage and the validation doesn't work.</p>
  
  <p>How can I to solve this problem? </p>
  
  <p>many thanks.</p>
  
  <p>code:</p>
  
  <pre><code>   &lt;script type="text/javascript"&gt;    
      $().ready(function()
      {         
      var validator = $("#aspnetForm").bind("invalid-form.validate", function() {         
         }).validate({
          errorElement: "em",
          errorContainer: $("#warning, #summary"),
          errorPlacement: function(error, element) {
              error.appendTo( element.parent("td").next("td") );
          },
              rules: {
                &lt;%=TextBoxCodigo.UniqueID %&gt;: {required: true}
                    },
              messages: {
                  &lt;%=TextBoxCodigo.UniqueID %&gt;:{required: "Requerido"}
                  }
          });
  
           $('#btnGuardar').click(function () {
              var txtUsuario = $('#&lt;%= TextBoxCodigo.ClientID %&gt;').val();
              if(validator.form())
               {            
  
                      $.msg({content: "valido"});
  
               }else{$.msg({content: "El formulario tiene " + validator.numberOfInvalids()   + " errores.&lt;br&gt; Por favor vea los detalles indicados."});}
          });
      });
  
      &lt;/script&gt; 
  
  
  
      public void btnGuardar_Click(object sender, EventArgs e)
      {
  
          BoClassCodigo boClassCodigo = new BoClassCodigo();
          boClassCodigo.CodigoDescripcion = TextBoxCodigo.Text;
          boClassCodigo.Sesion = new BoClassSesion();
          boClassCodigo.Sesion.Sesiones = (Int64)((Usuario) Session["uSession"]).Sesion;
          boClassCodigo.Sesion.Terminal = ((Usuario)Session["uSession"]).Usuario;
          string cad = BllClassCodigo.InsertarCodigo(boClassCodigo,conexion);
  
      }
  </code></pre>