Hi, I wanted to clear the validation errors if I clicked the Create Button.
Because if I click the Close Button or The Black Shadow(Accidentally close the modal) behinds the Modal within the state of "Errors" in validation, if I click the create button again, the errors will still show, which should be removed as I am clicking back "Create" button.
Please check this link below as reference, the only thing I wanted to do is everytime i click Create Button, the partial view must clear all errors even it was from the previous transaction because sometimes I accidentally drop the modal. Thanks in Advance.
https://qawithexperts.com/article/asp.net/validate-pop-up-modal-using-ajaxbeginform-in-c-mvc/52 ...(Make this as reference)
You can load/re-load your partial view using Ajax on opening modal pop-up instead of opening it using button use this jquery ajax call to open it and call partial view
// when DOM is ready
$(document).ready(function () {
// here #mybtn is id of button,clicking which you want to open pop-up
$("#mybtn").click(function(){
// show Modal
$('#myModal').modal('show');
$.ajax({
url:"/Home/PartialView",
type:'GET',
success: function(data){
//here frmEmp is id of div where you need to place returned html
$("#frmEmp").html(data);
},
error:function(){
alert("Error");
}
})
});
})
it should work and whenever you click the button, it will reload partial view using ajax, so it will validation error messages also.
$("table").on("click", "a[data-modal]", function () {
$id = $(this).attr("id");
$('#myModalContent').load('/Master/RevenueCodeRowDetailsEdit/'+$id, function () {
$('#myModal').modal({
keyboard: true
}, 'show');
bindForm(this);
});
return false;
})
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly