Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 42 people (36%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

how do i parse a textarea in javascript?

Apr 6th, 2008 19:31
ha mo, Dave Clark, Kumar S, suzette quinton,


Can you tell me what do you want to do with the data/text entered into
the textarea. 
Want to check maximum length or else ? Posting a clear question will
help me to answer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suzette,
     You may obtain the content of the textarea as follows:
var ele = document.forms['formName'].elements['textareaName'];
var str = ele.value;
     As for parsing that value, I would also need more information 
from you.  However, you can find the length as follows:
alert(str.length);
     You can also find out if the user created more than one paragraph 
of text (if the ENTER key was pressed within the TEXTAREA) as follows:
var ary = str.split("\n");
alert(ary.length);
     From there, there are all kinds of string manipulation methods 
you might employ.
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com