How to disable/enable submit button in jQuery
In this tutorial, we are going to see how to disable or enable submit button in jQuery. You can easily use the method prop() of jQuery to enable or disable form elements like <input>, <button>, <textarea>, etc. dynamically by using jQuery.
The prop() method requires a version of jQuery > 1.6. Here is an example:
How to disable/enable submit button in jQuery
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </head> <body style="text-align:center;"> <h1>StackHowTo</h1> <input id="input" type="text" name="input" disabled/> <button onclick="enable()">Enable / Disable</button> <script> function enable() { $("input").prop('disabled', false); } </script> </body> </html>
Result |
---|
StackHowTo |