Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-23-2004, 05:08 PM   PM User | #1
tinku
New Coder

 
Join Date: Dec 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
tinku is an unknown quantity at this point
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
tinku is offline   Reply With Quote
Old 12-23-2004, 05:32 PM   PM User | #2
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
<body onload="if(document.forms['FORM_NAME']['TEXTAREA_NAME'].value.length>0)alert('Textarea has value')"....
Willy Duitt is offline   Reply With Quote
Old 12-23-2004, 05:41 PM   PM User | #3
Badman3k
Regular Coder

 
Join Date: Jun 2002
Location: Edinburgh, UK
Posts: 402
Thanks: 2
Thanked 1 Time in 1 Post
Badman3k is an unknown quantity at this point
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."
Badman3k is offline   Reply With Quote
Old 12-23-2004, 07:26 PM   PM User | #4
tinku
New Coder

 
Join Date: Dec 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
tinku is an unknown quantity at this point
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?
tinku is offline   Reply With Quote
Old 12-23-2004, 07:53 PM   PM User | #5
Badman3k
Regular Coder

 
Join Date: Jun 2002
Location: Edinburgh, UK
Posts: 402
Thanks: 2
Thanked 1 Time in 1 Post
Badman3k is an unknown quantity at this point
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."
Badman3k is offline   Reply With Quote
Old 12-23-2004, 09:46 PM   PM User | #6
tinku
New Coder

 
Join Date: Dec 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
tinku is an unknown quantity at this point
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.
tinku is offline   Reply With Quote
Old 12-23-2004, 09:52 PM   PM User | #7
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
document.myForm.txtArea.focus();
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 12-23-2004, 09:54 PM   PM User | #8
tinku
New Coder

 
Join Date: Dec 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
tinku is an unknown quantity at this point
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..
tinku is offline   Reply With Quote
Old 12-24-2004, 01:32 AM   PM User | #9
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
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();
}
}
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:32 PM.


Advertisement
Log in to turn off these ads.