Enable & Disable Form Text Elements 
Author Message
 Enable & Disable Form Text Elements

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



Mon, 04 Feb 2002 03:00:00 GMT  
 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



Wed, 06 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. how to disable right-click contextMenu - but enable for form elements

2. Buttons: Disabling & Enabling INPUT Button

3. Enabling & Disabling proxy setting in IE4

4. Enabling-disabling of text boxes.

5. enable/disable text fields

6. x-browser way to disable form elements?

7. Check if form element is disabled

8. Finding # of specific element in forms elements collection

9. Disable/Enable mouse and keyboard

10. Enable/ Disable Show Pictures

11. enable/disable checkboxes dynamically

12. Can I disable/enable a table row??????????????????

 

 
Powered by phpBB® Forum Software