I have a standard form populated by an MVC model with standard [Required] validation. I want to "submit" this form data via AJAX, not by a submit, and I would like to take advantage of the built-in MVC/razor validation features. I can't figure out how to fire the client-side validation without triggering the form submit event.
Here is my razor markup:
@using (Html.BeginForm()) {
<span class="label">Team Name:</span> @Html.TextBoxFor(m => m.Name})
@Html.ValidationMessageFor(m => m.Name)
And here is my model:
public class Team
{
[Required(ErrorMessage = "Required")]
public string Name { get; set; }
It seems like this should be an easy thing to do. It works beautifully on submit. I just need to know how to invoke the validation method manually.