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 9 of 9

Thread: alert onload

  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    alert onload

    How can I alert onLoad for a text area only if it has text filled in only when that particular customer name is selected?
    Please help
    Last edited by tinku; 12-23-2004 at 05:33 PM. Reason: some more important point

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <body onload="if(document.forms['FORM_NAME']['TEXTAREA_NAME'].value.length>0)alert('Textarea has value')"....

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Well without knowing the name of the text area, you'd have to do something like this:
    Code:
    <html>
    <head>
    <title>temporary file</title>
    
    <script>
    function alertMsg(){
    
    if (document.myForm.txtArea.value != null){
         alert("The textarea has text in it");
       }
    }
    </script>
    
    </head>
    <body onLoad="JavaScript:alertMsg();">
    
    <form name="myForm">
    <textarea name="txtArea">value....</textarea>
    </form>
    
    
    </body>
    </html>
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #4
    New Coder
    Join Date
    Dec 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you Guys It helped.

    Quote Originally Posted by Badman3k
    Well without knowing the name of the text area, you'd have to do something like this:
    Code:
    <html>
    <head>
    <title>temporary file</title>
    
    <script>
    function alertMsg(){
    
    if (document.myForm.txtArea.value != null){
         alert("The textarea has text in it");
       }
    }
    </script>
    
    </head>
    <body onLoad="JavaScript:alertMsg();">
    
    <form name="myForm">
    <textarea name="txtArea">value....</textarea>
    </form>
    
    
    </body>
    </html>

    Thanks a lot!!
    and If I have to get a alert box when either one of the two textarea has comments? What should I do then?

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    So you want an alert message if either of two boxes has text in it?

    If so swap the original if statement for this one:
    Code:
    if ((document.myForm.txtArea1.value != null)&&(document.myForm.txtArea2.value != null)) {
    [...]
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #6
    New Coder
    Join Date
    Dec 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to get the focus on textarea

    It works fine.
    How can we get the focus to that text area where the length >0 that means after alert.
    Thank you in advance.

  • #7
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    document.myForm.txtArea.focus();

  • #8
    New Coder
    Join Date
    Dec 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you Specify where do I place the focus() line???/
    function validate(){
    if((document.forms['general_form']['comments'].value.length>0)||
    (document.forms['general_form']['custentitydrxcomments'].value.length>0)){
    alert('Please check the comments before making any changes.');
    }
    }
    Last edited by tinku; 12-23-2004 at 10:18 PM.

  • #9
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Uhm...you want it right after the alert? All you have to do is add that line:
    Code:
    function validate(){
    if((document.forms['general_form']['comments'].value.length>0)||
    (document.forms['general_form']['custentitydrxcomments'].value.length>0)){
    alert('Please check the comments before making any changes.');
    document.myForm.txtArea.focus();
    }
    }


  •  

    Posting Permissions

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