title: Use Remote validation in ASP.NET MVC without form on View
body: <p>I use <code>Remote</code> attribute on my <code>ViewModel</code> in <strong>ASP.NET MVC 4</strong> application. Here is my simple model:</p>
  
  <pre><code>public class User
  {
      [Required(AllowEmptyStrings = false, ErrorMessage = "test test")]
      public int Id { get; set; }
  
      [DisplayName("Email")]
      [Remote("RemoteValidateEmailLengthValidation", "Home")]
  
      public string Email { get; set; }
  }
  </code></pre>
  
  <p>And remote validation method:</p>
  
  <pre><code>public JsonResult RemoteValidateEmailLengthValidation(string Email)
  {
      if (Email.Length &gt; 20)
      {
          return Json("Too long email", JsonRequestBehavior.AllowGet);
      }
      else
      {
          return Json(true, JsonRequestBehavior.AllowGet);
      }
  }
  </code></pre>
  
  <p>I added all scripts that i need for validation on <code>Layout</code>:</p>
  
  <pre><code>@Scripts.Render("~/bundles/jquery")
  @Scripts.Render("~/bundles/jqueryui")
  @Scripts.Render("~/bundles/jqueryval")
  </code></pre>
  
  <p>Write all that i need for validation in <code>WebConfig</code>:</p>
  
  <pre><code>&lt;add key="ClientValidationEnabled" value="true" /&gt;
  &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
  </code></pre>
  
  <p>And add simple <code>Controller</code> that creates empty model and return <code>View</code>.</p>
  
  <pre><code>@model ViewModels.User
  
  @{
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  @using (Html.BeginForm("PostUser", "Home", FormMethod.Post))
  {
      @Html.EditorForModel()
      &lt;input type="submit" /&gt;
  }
  </code></pre>
  
  <p>It works only if i wrap my model in <code>form</code> and <strong>doesn't work</strong> if i write my <code>View</code> like this:</p>
  
  <pre><code>@model ViewModels.User
  
  @{
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  @Html.EditorForModel()
  </code></pre>
  
  <p>So i have questions:</p>
  
  <ol>
  <li>Why remote validation doesn't work without form? Because in Chrome debugger i see that form don't submit i see only Validation method call.</li>
  <li>Which javascript method used by Remote validation? <code>OnChange</code>? Can i see it anywhere and can i change it?</li>
  </ol>