title: Validation before posting ASP.NET MVC form
body: <p>I have this :</p>
  
  <pre><code>@using (Html.BeginForm("Action", "Controller", FormMethod.Post))
  {
  @Html.TextBoxFor(m =&gt; m.City, new { id = "tbCity", maxlength = 50 })
  &lt;input type="submit" value="Save" class="btSave" /&gt;
  }
  </code></pre>
  
  <p>I'd like do a sublit make some validation (check if "tbCity" as a length != 0), I created a function with all validation, how can I call here ? and cancel if the validation is not correct ?</p>
  
  <p>Thanks,</p>
  
  <p><strong>Update1</strong></p>
  
  <p>@Adam Pope : 
  Imagine, I have a datalodel names "Person"s (firstname, lastname, ...), a model class with  <code>public Person Person{ get; set; }</code>, where use the [Required] attribute ?</p>