title: Jquery Validate doesn't work in MVC C#
body: <p>I'm working on a MVC App and I need to check if a user is registered, for that purpose I've created a model</p>
  
  <pre><code>public class Ejemplo
   {
     [Required(ErrorMessage="Favor especificar Username")]
     [DataType(DataType.Text)]
     public string usuario { get; set; }
  
     [Required(ErrorMessage="Favor especificar password")]
     [DataType(DataType.Password)]
     public string password { get; set; }
   }
  </code></pre>
  
  <p>my problem so far is that I need to send the info of the user in a JSON format via AJAX and I need to validate that the username and password info are specified, in order to accomplish that I' coded this:</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta name="viewport" content="width=device-width" /&gt;
      &lt;title&gt;Index&lt;/title&gt;
      &lt;script src="~/Scripts/jquery-1.10.2.js"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/jquery.validate.js"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/jquery.validate.unobtrusive.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
  
          $('#myform').validate({ // initialize the plugin
              rules: {
                  usuario: {
                      required: true,
                      minlength: 12
                  },
                  password: { required: true }
              },
              messages: {
                  usuario: {
                      required: "must specify username --&gt; validate !!!",
                      minlength: "not a valid Lenght --&gt; validate !!!"
                  },
                  password: {
                      required: "must specify a password --&gt; validate !!!"
                  }
              },
               submitHandler:
                      $("#myform").on('submit', function () {
                          alert("have just pressed submit");
                          if ($("#myform").valid()) {
                              alert("here some code inside $.AJAX({})");
                          }
                          return false;
                      })
          })
      });
  </code></pre>
  
  <p>and this is my form(the code above and the form are in the same file: Index.cshtml)</p>
  
  <pre><code>&lt;fieldset&gt;
   &lt;legend&gt; Validaciones MVC &lt;/legend&gt;
    @using (Html.BeginForm("Prueba", "Prueba", FormMethod.Post, new { @id = "myform" }))
    {
  
       @Html.LabelFor(M =&gt; M.usuario);
       &lt;br /&gt;
       @Html.EditorFor(M=&gt;M.usuario)
       @Html.ValidationMessageFor(M =&gt; M.usuario);
       &lt;br /&gt;
       @Html.LabelFor(M=&gt;M.password)
       &lt;br /&gt;
       @Html.EditorFor(M=&gt;M.password);
       @Html.ValidationMessageFor(M=&gt;M.password)
       &lt;br /&gt;
       &lt;br /&gt;
  
    &lt;input type="submit" id="boton_id" name="boton_name" value="Enviar" /&gt;
                  }
          &lt;/fieldset&gt;
  </code></pre>
  
  <p>but it doesn't validate and doesn't show any message in case the username and password are empty, it only shows this alert:  alert("have just pressed submit"); but never shows the second alert:  alert("here some code inside $.AJAX({})"); this two alert are in </p>
  
  <pre><code>submitHandler:
                      $("#myform").on('submit', function () {
                          alert("have just pressed submit");
                          if ($("#myform").valid()) {
                              alert("here some code inside $.AJAX({})");
                          }
                          return false;
                      })
  </code></pre>
  
  <p>so, could you please help me and tell me where is my problem or what I' missing please?</p>