Disable Html Button Using JavaScript

For More Videos Visit Our YouTube Channel




Here we consider how to Disable Html Button Using JavaScript. We have already discussed how to disable buton using Jquery in the following link. Disable Html Button Using Jquery

But here we discuss purely on JavaScript. Lets start with one example here. Suppose we have a Button with ID btnID as shown below.

Disable Html Button Using JavaScript, How To Disable Html Button Using JavaScript, Disable Html Button Using JS, JavaScript Disable Html Button, Disable Html Button Using Jquery, Jquery Disable Html Button, Disable, Html Button, Button, Disable Button, JavaScript

Now for disabling this Button using JavaScript, follow this code.

document.getElementById("btnID").disabled = true;



Now to Enable back the Button, just add following code.

document.getElementById("btnID").disabled = false;



That's all, by this way we can enable or disable any form element by JavaScript. Just specify your form element ID within getElementById.