Reputation: 599
I want to disable a form once I submit it. I tried this but it doesn't disable the form:
$( "#myform" ).prop("disabled", true);
I am using jQuery/php/ajax. When the user clicks submit the submit button is disabled and a spinner displays in the button. Server side validation is done and errors are displayed or an email is sent and success message is displayed. In that time when the spinner is going, I don't want the user to be able to change anything on the form like click another radio button for example. The form is pretty quick but you never know..
Upvotes: 0
Views: 1079
Reputation: 218798
I don't think you can "disable" a <form>
element. But if its contents are wrapped in a <fieldset>
then you can easily disable that:
<form id="myform" method="POST" action="test.php">
<fieldset>
<input type="text">
<textarea></textarea>
<input type="submit">
</fieldset>
</form>
And:
$( "#myform fieldset" ).prop("disabled", true);
Upvotes: 3