In this tutorial, learn how to disable every form elements using jQuery. The short answer is: use jQuery prop() to disable all form controls in jQuery. The user cannot be able to click the form elements after you disable them.
First of all, you can use jQuery to enable or disable form elements easily. While developing forms, many times maybe you come up with a problem to stop user input. Therefore, After fulfill of certain requirements, you may allow users to enter input data.
How to Disable Every Form Elements Using jQuery
With the above all requirement, you have to use the prop function with two arguments. The first argument is the attribute to add the HTML element. The another argument is the value of the attribute to be true.
As a result, the true value makes all the input to become disabled. You are almost done disabling all input fields of form.
<input type="text" class="form-control" name="Name"/>
<input type="text" class="form-control" name="Email"/>
<input type="text" class="form-control" name="Message"/>
<input type="button" class="btn btn-primary" value="Submit" name="submit"/>
Finally, take your mouse to any input fields including the button element. So, All the inputs are in disable condition. Due to this, you are not allowed to click any input field and enter data.
Also, take your mouse to each and every form elements. This is the simple method to disable every form elements.
Stop allowing users to input any values in the form. You may also like to read how to display or show form on button click using jQuery.
Hope, you like this tutorial of how to disable every form elements. If you have any query regarding the tutorial, please comment below.
Also tell me, which method are you using to disable form controls.