earlier I asked for help disabling a Button when a drop down menu item was selected. I was given some code that did the trick but now I need the same with a Textbox and for some odd reason its not working can you have a look for me...
HTML:
<form id="frmColor">
<input type='TextBox' id='color' />
<input type='submit' value='Change Color' id="colorSubmit"/>
</form>
Javascript:
tools.eraser = function () {
var tool = this;
this.started = false;
var varPenColor = "White";
context.strokeStyle = varPenColor;
document.getElementById('frmColor').colorSubmit.disabled=true;
document.getElementById('frmColor').color.disabled=true;
Any ideas why it wont disable the text box?
Thanks
This question is related to
javascript
html
Here was my solution:
Markup:
<div id="name" disabled="disabled">
Javascript:
document.getElementById("name").disabled = true;
This the best solution for my applications - hope this helps!
You can use disabled attribute to disable the textbox.
document.getElementById('color').disabled = true;
With the help of jquery it can be done as follows.
$("#color").prop('disabled', true);
Source: Stackoverflow.com