Im using mvc 2, my view is as follows
<% using (Html.BeginForm("ApplyLeave", "ESS", FormMethod.Post, new { id = "formApplyLeave" }))
{ %>
<fieldset>
<div>
<div>
<label for="FromDate">
From</label></div>
<div>
<%=Html.TextBoxFor(l => l.FromDate, new { id = "FromDate", name = "FromDate", maxlength = 10 })%>
</div>
<div>
<%=Html.ValidationMessageFor(l => l.FromDate)%></div>
</div>
<div>
<div>
<label for="ToDate">
To</label></div>
<div>
<%=Html.TextBoxFor(l => l.ToDate, new { id = "ToDate", name = "ToDate", maxlength = 10 })%>
</div>
<div>
<%=Html.ValidationMessageFor(l => l.ToDate)%></div>
</div>
</fieldset>
<% } %>
and for submitting the form, im using jquery as
$('#formApplyLeave').submit();
I wrote the validation in attributes in model.
Here im able to submit the form, but validation are not getting fired. How do i fire the validations in jquery, before submitting the form.
please help.
You could use the beforeSubmit callback to set values:
Or using jQuery validation plug-in’s validate method
try like this~
This way validation will be triggered by your submit event handler.