Dear All,
I am trying to post an MVC page using AjAX and this page (view) is 'strong typed' and its model has all the data annotation.
On posting the page, JS validation has not been raised and 'ModelState.IsValid' always equal to TRUE.
Note: I am not posting the entire page, I am just posting some fields to the action.
So can you help if there is a way to fire JS validation?
Thanks
What I have tried:
I just made sure that my model has all the required data annotations and all the JS script files are included in my bundle.
$.ajax({
url: "@Url.Action("XXX")",
type: "post",
data: {
__RequestVerificationToken: $("[name='__RequestVerificationToken']").val(),
id: $("#Id").val(),
name: $("#Name").val(),
remarks: $("#Description").val(),
level: $("#level").val(),
status: $("#Status").val(),
memebers: x
},
datatype: "json",
success: function (data) {
alert(data.msg);
if (data.result)
{ window.location.href = "@Url.Action("Index")";}
},
error: function (data)
{ $("#loading").hide(); alert("Erorr while processing your request"); },
complete: function (data)
{ $("#loading").hide(); }
});