Current location: Hot Scripts Forums » General Web Coding » JavaScript » [SOLVED] textarea value


textarea value

Closed Thread
  #1 (permalink)  
Old 02-22-10, 06:15 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
textarea value

Hi there,

I want javascript to check if there is text in my textarea. I wrote this piece of javascript,
but somehow it always says it's empty.

Code:
if(document.getElementById("uiterlijk").value == ""){  
		 document.getElementById("truiterlijk").style.backgroundColor = "red";
		 error++; 
	  } else {
	  	document.getElementById("truiterlijk").style.backgroundColor = "#ffffff";
	  }
my html looks like:

HTML Code:
<tr style="background-color:#ffffff;" id="truiterlijk">
		<td valign="top" style="padding:5px 0px 0px 5px;" align="left">uiterlijk</td>
		<td style="padding:3px 0px 3px 15px; min-width:40px;" align="left">		
			<textarea id="uiterlijk" name="uiterlijk" class="inputtext" style="height:150px;"></textarea>		
		</td>
	</tr>
How to check this? I assume it's because there is no "value" tag in the textarea part.
But there shouldn't be one. How to check for text anyway?.

_j
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #2 (permalink)  
Old 02-22-10, 06:42 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
I think your code should work as it is.

HTML DOM Textarea Object
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #3 (permalink)  
Old 02-22-10, 06:46 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
that's what I thought too, but the backgrounColor is set to red no matter if there is text in the area.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #4 (permalink)  
Old 02-22-10, 07:34 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
When is the javascript executed? On submit?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #5 (permalink)  
Old 02-22-10, 07:59 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
yes it is executed on submit.

Other parts that check a single line input and select input work fine, except this textarea part.

I just found it has something to do with the TinyMCE editor I'm using. This mess up the value.
If I disable it, there is no problem.

Last edited by jonnekke; 02-22-10 at 08:18 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
raeding textarea in textarea Wanasa PHP 3 05-30-09 03:28 AM
inserting a line of code on current cursor possition into textarea sujata_ghosh JavaScript 12 08-21-07 08:22 AM
Editing text in Textarea html control sudidelaravindra JavaScript 1 09-15-06 11:17 AM
Preview text from a TEXtAREA using PHP?? KeYBLeR PHP 7 03-02-06 10:18 AM
How to import the textarea data into database superman2004 ASP 2 03-31-05 09:37 AM


All times are GMT -5. The time now is 10:11 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.