
Enable & Disable Form Text Elements
Hi,
you may use the disable property (of boolean type) via this scheme:
document.formname.elementname.disabled = true || false
just as in this simple example:
<HTML>
<SCRIPT>
function disable(bValue){
document.myForm.myInputText.disabled = bValue;
Quote:
}
</SCRIPT>
<FORM NAME=myForm>
<INPUT TYPE=text NAME=myInputText>
<INPUT TYPE=button VALUE=disabling onClick="disable(true)">
<INPUT TYPE=button VALUE=enabling onClick="disable(false)">
</FORM>
</HTML>
Note: neither DISABLED keyword nor disabled property has an effect
on text inputs in NS. So if you still want a cross platform method for
disabling text inputs you should make your own. For instance via this
trick
onFocus = "this.Blur()"
you can get a crossplatform disabling method, like in this example
<HTML>
<SCRIPT>
function blurElement(){
this.blur()
Quote:
}
function disable(element, bValue){
if (bValue&!element.disabled){
element.disabled = true;
element.onoldfocus = element.onfocus;
element.onfocus = blurElement;
}
else{
if (!bValue&element.disabled){
element.disabled = false;
element.onfocus = element.onoldfocus;
}
}
Quote:
}
</SCRIPT>
<FORM NAME=myForm>
<INPUT TYPE=text NAME=myInputText>
<INPUT TYPE=button VALUE=disabling onClick="disable(myForm.myInputText, true)">
<INPUT TYPE=button VALUE=enabling onClick="disable(myForm.myInputText, false)">
</FORM>
</HTML>
Csomi
Quote:
>Hi,
> Does anyone know if it is possible to programmatically enable or disable a
>text element created like:
><FORM Name="DataForm1">
><TEXT Name = "Text1">
>I can make it disabled at the beginning by including the "DISABLED" keyword
>in the text tag, but I can't figure out how to access the property
>programmatically.
>Thanks,
>- Brendan