Web Analytics Made Easy -
StatCounter Text box disabling - CodingForum

Announcement

Collapse
No announcement yet.

Text box disabling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Text box disabling

    Hi,

    i have 2 text boxes in my form.Value for both of them need not be entered by the user but if he enters value in one text box then the other one should automatically be disabled.

    But if the user removes value in the textbox again both fields should be editable,similarly for the other textbox.


    How do i achieve this using javascript


    Thanks

    Rama

  • #2
    page charset-encoding in case of document.write()

    HI!
    You can use a

    funuction nnn(){
    if(!this.form_name.txt_box1_name.value){
    this.form_name.txt_box1_name.disabled=true;
    this.form_name.txt_box2_name.disabled=true;
    }

    and to put into txtbox input tag this

    onBlur="nnn()"

    it executes a function nnn() when visitor leave your txtbox and the function checks IS FIRSTBOX empty. If YES, it disabled txtboxes.

    OK?
    hryan
    New to the CF scene
    Last edited by hryan; Jul 7, 2002, 08:54 AM.

    Comment


    • #3
      Hi,

      There was some problem with the if condition in the function and then i removed ! from it and it worked ,similarly i did for the other textbox it is working fine.


      Thanks

      Rama
      rama
      New to the CF scene
      Last edited by rama; Jul 7, 2002, 10:34 AM.

      Comment


      • #4
        <html>
        <head>
        <title>untitled</title>
        </head>
        <body>
        <form>
        <input name="t1" type="text"
        onkeypress="t2.disabled=this.value"
        onblur="t2.disabled=this.value"><br>
        <input name="t2" type="text"
        onkeypress="t1.disabled=this.value"
        onblur="t1.disabled=this.value"><br>
        </form>
        </body>
        </html>
        adios
        New to the CF scene
        Last edited by adios; Jul 7, 2002, 07:24 PM.

        Comment


        • #5
          Hi !


          if(!this.form_name.txt_box1_name.value) is equal to

          if(this.form_name.txt_box1_name.value==NULL)

          but you may use instead it conditions:

          if(this.form_name.txt_box1_name.value!='') //if no empty string ...
          or
          if(this.form_name.txt_box1_name.value=='') //if empty string ...

          Comment

          Working...
          X