Friday, March 27, 2009

Tab Stop on Disabled Text Boxes

One option is to add the onkeyup attribute to the input element for the quantity that will check if the disabled text box qualifies to be enabled and if yes enables it. The code snippet below has a successfully tested example that is simple.The onkeyup event of the quantity input element is called immediately after the user entered something into the quantity field, we then check if the criteria is met and if yes enable the initially disabled text box so that by the time the user tabs to it, it is already enabled and the tab works.

input type="text" id="txtQuantity" onkeyup="if(this.value != '') { document.getElementById('txtSecondBox').disabled = false; }" />

input type="text" id="txtSecondBox" disabled="disabled" />

No comments: