jQuery in Action, 3rd edition
The moose likes HTML, CSS and JavaScript and the fly likes textarea tag -  Entering string problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "textarea tag -  Entering string problem" Watch "textarea tag -  Entering string problem" New topic

textarea tag - Entering string problem

garfild Baram
Ranch Hand

Joined: Mar 24, 2003
Posts: 60
Hi helper,
I'm using <textarea> tag to insert a query string to use it for a database report.
It works well as long as I dont use Enter key.
Without using Enter key in the textarea I get:
String = "Select * from TableName"
Writing this string in the textarea and using EnterKey I get:
String = "Select *fromTableName"
(I pressed the Enter Key after "*" and after "from".
This query that I get doesnt allow me to create a resultset.
How can I insert spaces after pressing the Enter Key?
Please advise
garfild Baram
Ranch Hand

Joined: Mar 24, 2003
Posts: 60
I inserted the following routine to replace \n char with apace and it works well.
public static CharSequence removeLineTerminator(CharSequence inputStr) {
String patternStr = "\\n";
String replaceStr = " ";
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
return matcher.replaceAll(replaceStr);

Thanks any way
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
There may be a simpler solution. It looks like the textarea processing in the browser is simply removing newlines. Have you checked out the "wrap" options available for the textarea tag? If you haven't, you may find that one of them produces the effect you require, without extra processing.
This bulletin board "post a reply" form I'm typing into uses <textarea wrap='virtual'> for example.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
garfild Baram
Ranch Hand

Joined: Mar 24, 2003
Posts: 60
No I didn't try it but I will.
Thanks a bunch Frank
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63869

Since this is a client-side issue, I'm moving this to the HTML/Javascript forum for future reference.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: textarea tag - Entering string problem
It's not a secret anymore!