title: How can i prevent User click the button to submit form if specify field is not valid?
body: <p>I have a jquery function to check valid data on <code>UsernameTextbox</code> in my View. I want to prevent User click on the <code>Register</code> button until this field valid. </p>
  
  <p>Disable button is it the best method? I just want when the value is not valid, user click on button just focus to the <code>UsernameTextbox</code> filed?</p>
  
  <p>Update Code: </p>
  
  <p>Here is my Model : </p>
  
  <pre><code>    [Required]
      [Remote("CheckUsername", "Account", ErrorMessage = "Username already exits.")]
      public string Username { get; set; }
  </code></pre>
  
  <p>and Controller with GET method:</p>
  
  <pre><code>[HttpGet]
      public JsonResult CheckUsername(string userName)
      {
          var user = IUserRepo.GetUserByUrName(userName);
          bool isValid = true;
          if (user!=null)
          {
              isValid = false;
          }
          return Json(isValid, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>and in my View :</p>
  
  <pre><code> @using (Ajax.BeginForm("Register","Account",new {area = "Area"},null))
      {
          @Html.ValidationSummary(true) 
          &lt;table&gt;
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;td class="info_label"&gt;Tên đăng nhập&lt;/td&gt;
                      &lt;td&gt;@Html.EditorFor(m =&gt; m.User.Username)
                      &lt;/td&gt;
                      &lt;td class="check_user"&gt;@Html.ValidationMessageFor(m =&gt; m.User.Username)&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt; ........
  </code></pre>
  
  <p>Why no error message appear? And i want to valid intermediately when user fill data or leave textbox like this site <a href="http://yame.vn/TaiKhoan/DangKy" rel="nofollow">http://yame.vn/TaiKhoan/DangKy</a>.</p>