views:

54

answers:

1

Hi folks, on a page with textbox control, lets say this textbox is disabled on server side page load. What would happen if a javascript tries to set visibility of the textbox to false ?

Edit: Can the textbox be hidden by javascript even though it's disabled ?

TIA

+1  A: 

Yes, setting disabled on the serverside only adds the disabled attribute.

Nate Bross
are you saying disabled textbox visibility can be set to false by javascript ?
SoftwareGeek
You can't set it to false. You need to actually remove the disabled attribute via Element.removeAttribute("disabled") from the textbox on the client-side if you want to enable it. disabled="false" is still disabled. It has to do with older HTML where the attribute used to be just disabled. Because of XHTML you usually see this though disabled="true". But all of these mean it's disabled: disabled="true", disabled="false", disabled="bob", disabled="WTF"
nickyt
@nickyt - see my edit.
SoftwareGeek
@Wisdom - You can use CSS to hide it regardless of whether or not it's disabled. Either visible: hidden or display: none . Here's an explanation of the difference, http://www.devx.com/tips/Tip/13638 . So on IE6+ and other modern browsers you can usually just do this: someElement.style.display="none" or someElement.style.display="hidden" or you can use a framework like jQuery to do this, e.g. $("#someElementId").css("display", "none");
nickyt