Hi
I have a partial view with a form, when I am clicked on the submit button there is no validation error message.
This is what I have:
@using (Html.BeginForm("GetPartialView", "Manage", FormMethod.Post, new { enctype="multipart/form-data", id = "LoginForm" }))
{
@Html.AntiForgeryToken()
<div class="form-group">
@Html.LabelFor(model => model.Isbn)
@Html.EditorFor(model => model.Isbn, new { htmlAttributes = new { @class = "form-control" } })
<button id="loginButton" class="btn btn-common-small" type="button">Opret</button>
}
What I have tried:
I have tried this jquey.
jQuery(document).ready(function ($) {
$('#loginButton').click(function () {
$.ajax({
type: "POST",
url: '@Url.Action("GetPartialView", "Manage")',
data: $('form').serialize(),
success: function (result) {
var form = $('#LoginForm');
if (result.redirectTo) {
window.location.href = result.redirectTo;
} else {
$("#LoginFormContainer").html(result);
form.data('validator', null);
$.validator.unobtrusive.parse(form);
}
},
error: function () {
$("#LoginForm").html(result);
}
});
});
});
But this is only work if I change the button type from submit to button, but then my fileupload wont work.
/Tina