I have the following code that contains validation:
<div id="ContactDialog" style="display: none;">
@Html.LabelFor(model => model.subject)
@Html.TextBoxFor(model => model.subject, new { @class = "AboutControls" })
@Html.ValidationMessageFor(model => model.subject)
<br /><br />
@Html.LabelFor(model => model.from)
@Html.TextBoxFor(model => model.from, new { @class = "AboutControls" })
@Html.ValidationMessageFor(model => model.from)
<br /><br />
@Html.LabelFor(model => model.body)
@Html.TextAreaFor(model => model.body, new { @class = "AboutControls" })
@Html.ValidationMessageFor(model => model.body)
<hr />
<br /><br />
</div>
This code is executed from JQuery ajax code. Because of this, the validation is not triggered. All the fields are required, but since they are not called through an <input type="submit" value="..." />
the validation is not triggered, and they will go through even when they are null, resulting in an exception. How can I make sure the validation is triggered even when no using an <input ... />
?