Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

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


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
     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:
     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");
     From there, there are all kinds of string manipulation methods 
you might employ.
Take care,
Dave Clark