Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 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
    New Coder
    Join Date
    Jun 2002
    Location
    Bulgaria
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?
    Last edited by hryan; 07-07-2002 at 12:54 PM.

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by rama; 07-07-2002 at 02:34 PM.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    <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>
    Last edited by adios; 07-07-2002 at 11:24 PM.

  • #5
    New Coder
    Join Date
    Jun 2002
    Location
    Bulgaria
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ...



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •