Hello Guys,
I am following this post Disable Button after click to prevent double clicking in ASP.Net MVC to disable the button during postback but the issue here is, it is disabling even if there are model state errors & is not getting enable if there is a validation failed.
Below is my current code.
$(function () {
var enabled = '@ViewData["IsEnabled"]'
if (enabled == 'False') {
$(this).removeAttr("disabled");
$(this).val("حفظ /Save");
}
$('#btnSave').on('click', function () {
//if( $('form').isValid())
// {
$(this).attr('disabled', 'disabled');
$(this).val("معالجة/Processing.....");
$('form').submit();
//}
});
});
public ActionResult Create(Registration registration)
{
ViewData["IsEnabled"] = false;
if (ModelState.IsValid)
{
//perform the steps
}
}