Reputation: 224
I have a form like so:
<form action="" method="post" id="form" name="form" enctype="multipart/form-data">
<input name="action" type="submit" value="Send" />
</form>
I am using the latest version of the Jquery UI Button plugin. The value of the submit button MUST be submitted. Is there an easy way to disable the submit button after the form has been submitted, without using additional plugins such as "Lock Submit" - http://plugins.jquery.com/project/LockSubmit ?
Many thanks.
Upvotes: 0
Views: 2573
Reputation: 272006
When you set the disabled property of an element, it won't be submitted. The workaround is to set the disabled property after the form is submitted. You can use the setTimeout()
function with a very short delay:
$("#form").submit(function() {
setTimeout(function() {
// .prop() requires jQuery 1.6 or higher
$("#form :submit").prop("disabled", true);
}, 100);
});
Another trick, is to use a trick :) You can wrap the original submit button inside a div and hide it when the form submits.
Upvotes: 3
Reputation: 158
Easy just add type="button" to button attributes like
<button type="button" >not submit</button>
Upvotes: 3
Reputation: 222040
$('#form').submit(function() {
$(this).find('input[type="submit"]').disable();
});
Upvotes: 0
Reputation: 8049
you mean
$('#form').submit(function() {$(this).find('input:[type="submit"]').button({disabled:true})});
?
Upvotes: 0