tinku
12-23-2004, 05:08 PM
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
Please help
|
||||
alert onloadtinku 12-23-2004, 05:08 PM 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 Willy Duitt 12-23-2004, 05:32 PM <body onload="if(document.forms['FORM_NAME']['TEXTAREA_NAME'].value.length>0)alert('Textarea has value')".... Badman3k 12-23-2004, 05:41 PM Well without knowing the name of the text area, you'd have to do something like this: <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> tinku 12-23-2004, 07:26 PM Well without knowing the name of the text area, you'd have to do something like this: <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? Badman3k 12-23-2004, 07:53 PM 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: if ((document.myForm.txtArea1.value != null)&&(document.myForm.txtArea2.value != null)) { [...] :thumbsup: tinku 12-23-2004, 09:46 PM 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. Brandoe85 12-23-2004, 09:52 PM document.myForm.txtArea.focus(); tinku 12-23-2004, 09:54 PM 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.'); } } Brandoe85 12-24-2004, 01:32 AM Uhm...you want it right after the alert? All you have to do is add that 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.'); document.myForm.txtArea.focus(); } } |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum