praveen1981
asked on
Form validation in mvc
Hi
I am doing client side validation in mvc4 razor
which is working fine, but i want to do an ajax call once
the form is valid,then it is not validating properly,
i am using following scripts
<script src="~/Scripts/jquery-1.7. 1.min.js"> </script>
<script src="~/Scripts/jquery.vali date.js">< /script>
<script src="~/Scripts/jquery.vali date.unobt rusive.js" ></script>
@using (Html.BeginForm("EmployeeP ost", "Employee", FormMethod.Post, new { id="frm"}))
{
// i have necessary controls and submit button as follows
<input type="submit" value="submit" />
}
<script>
$(function () {
$('#frm').submit(function () {
if ($(this).valid()) {
alert('the form is valid');
// goes with ajax call
}
else {
alert('Invalid');
}
});
});
</script>
now here , if i don't enter required field values ,it is
giving me correct invalid message, but even after entering all
the required field values still it is giving invalid message,
i.e it is giving invalid message all the time, so, it is not
validating properly,
could you please suggest me what is the wrong in above code.
Many thanks.
I am doing client side validation in mvc4 razor
which is working fine, but i want to do an ajax call once
the form is valid,then it is not validating properly,
i am using following scripts
<script src="~/Scripts/jquery-1.7.
<script src="~/Scripts/jquery.vali
<script src="~/Scripts/jquery.vali
@using (Html.BeginForm("EmployeeP
{
// i have necessary controls and submit button as follows
<input type="submit" value="submit" />
}
<script>
$(function () {
$('#frm').submit(function () {
if ($(this).valid()) {
alert('the form is valid');
// goes with ajax call
}
else {
alert('Invalid');
}
});
});
</script>
now here , if i don't enter required field values ,it is
giving me correct invalid message, but even after entering all
the required field values still it is giving invalid message,
i.e it is giving invalid message all the time, so, it is not
validating properly,
could you please suggest me what is the wrong in above code.
Many thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER