I create ASP .NET MVC application. On button click I call JavaScript that disable same button.
After that (button has property readonly disabled) post action doesn’t call. When I remove JavaScript that disable buttons everything is fine. This happens only in the Google Chrome.
When I try same example in Firefox or Internet Explorer everything is fine.
<script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
Enable();
});
function Enable() {
$('#btn').removeAttr('disabled');
$('#btn').removeAttr('readonly');
}
function Disable() {
$('#btn').attr('disabled', 'true');
$('#btn').attr('readonly', 'true');
}
</script>
<h2>Example</h2>
<form>
<input id="btn" type="submit" value="StackOverflow" onclick="Disable()" />
</form>
You need to call form.submit() before disabling the button, and return false from your event handler.