title: MVC 3 specifying validation trigger for Remote validation
body: <p>I have implemented remote validation using MVC 3 unobtrusive validation as follows</p>
  
  <p>The model</p>
  
  <pre><code>public class MyViewModel {
      [Remote("ValidateAction", "Validation")]
      public string Text { get; set; }
  }
  </code></pre>
  
  <p>The Controller</p>
  
  <pre><code>public partial class ValidationController : Controller
  {
      public virtual JsonResult ValidationAction(string aTextToValidate)
      {
          if(aTextToValidate == /* some condition */)
              return Json(true, JsonRequestBehavior.AllowGet);
          return Json("This is not valid, Try Again !", JsonRequestBehavior.AllowGet);
      }
  }
  </code></pre>
  
  <p>The View</p>
  
  <pre><code>@using (Html.BeginForm() {
      @Html.TextBoxFor(m =&gt; m.Text)
      @Html.ValidationMessageFor(m =&gt; m.Text)
  }
  </code></pre>
  
  <p>And that's it, it all works, but ValidationAction is fired on every key press, which is not ideal, I would like just to fire when the element looses focus, but cannot figure how to do this</p>
  
  <h2>UPDATE</h2>
  
  <p>Actually I have noted that, by default, the validation does fire onBlur once .i.e. the first time the element looses focus, however when attempting to correct it, validation then fires onKeyUp. I think this is intended functionality and thinking about it is probably quite useful. However it would be useful to know if it is possible to modify this behaviour</p>