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 3 of 3
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    tips on what I am meant to search for please

    Hi,

    I can;t think what to search for but I need the following.

    I am running a form and if data is entered to the first text box, I want a warning message to show up, if they try to add data to any one of several other textboxes.

    tips on search terms would be great or a link to what might be some loosely appropriate code.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,507 Times in 2,485 Posts
    Try this:-


    Code:
    1 <input type = "text" id = "box1"><br>
    2 <input type = "text" id = "box2" value = "Some text in box 2" onfocus = "stop()"><br>
    3 <input type = "text" id = "box3" value = "Some text in box 3" onfocus = "stop()"><br>
    4 <input type = "text" id = "box4" value = "Some text in box 4" onfocus = "stop()"><br>
    <br>
    
    <script type = "text/javascript">
    function stop() {
    if (document.getElementById("box1").value.length > 0) {
    alert ("You may not alter the content of this field while box 1 contains anything");
    document.getElementById("box1").focus();  // set the focus away from box2-4
    document.getElementById("box1").blur(); //and suppress it
    return false;
    }
    }

    "If you don't read the newspaper, you are uninformed; if you do read the newspaper, you are misinformed." - Mark Twain

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Thank you Philip.

    I'll try that out.

    Since posting, I had got as far as dynamic form validation but not yet to any appropriate results.


    I really must begin to learn js soon.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

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