UncleCoder.com

UncleCoder.com

Free programming examples and instructions

Remove disabled attribute from html control

Code, example and demo for how to remove disabled attribute from html control

by Athil


Posted on 04 May 2017 Category: Javascript Views: 1390

Edited on 25 Jul 2018


DEMO

Hi, here I am going to show to enable HTML control through javascript. By using 

Method 1

document.getElementById('ControlId').disabled = false;

Method 2 

 document.getElementById('ControlId').removeAttribute('disabled');

Full Example

<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>
<script>

function removeDisbled()
{
    document.getElementById('txtname').disabled = false;
}
function removeDisbled2()
{
    document.getElementById('txtname2').removeAttribute('disabled');
}
</script>

</html>


Leave a Comment:


Advertisement