Remove disabled attribute from Html control using Javascript
Demo and code for how to enable a control in javascript
by Athil
Posted on 01 Jan 0001 Category: Javascript
Views: 7158
Here I am going to show how to enable an HTML control in Javascript.
DEMO
DOWNLOAD DEMO
Method 1
document.getElementById('txtname').disabled = false;
Where 'txtname' is the control id
Method 2
document.getElementById('txtname2').removeAttribute('disabled');
Where 'txtname2' is the control id
Full demo code
<!DOCTYPE html>
<html>
<h3>
Demo for remove disabled attribute from Html Control
</h3>
<p>Click the button to remove disabled attribute of textbox</p>
<h3>Method 1</h3>
<input type="text" id="txtname" disabled="true">
<button id="tbnRemove" onclick= "removeDisbled();" >Remove disabled </button>
<br/>
<h3>Method 2</h3>
<input type="text" id="txtname2" disabled="true">
<button id="tbnRemove" onclick= "removeDisbled2();" >Remove disabled </button>
<br/>
<script>
function removeDisbled()
{
document.getElementById('txtname').disabled = false;
}
function removeDisbled2()
{
document.getElementById('txtname2').removeAttribute('disabled');
}
</script>
</html>
Latest posts in Javascript