My problem is I am using the MVC3’s feature of unobtrusive client side validation but I need to hook into it and add a function that fires on a successful validation but before the form is posted.
I’m hoping there is some pre-built helper or an easy way to hook into the validator.
Here’s a code snippet:
@using (Html.BeginForm("MyAction","MyController")) {
@Html.ValidationSummary(true)
<fieldset> <legend><legend>
<label for="FirstName">First Name</label>
@Html.TextBoxFor(model => model.FirstName)
@Html.ValidationMessageFor(model => model.FirstName)
I ended up needing to hook into the validation process to perform my own custom validation and also do some div collapsing. Here’s a snippet of jQuery that accomplished what I needed: