We help IT Professionals succeed at work.

Textarea input truncates paste from notepad after 1st carriage return in IE

llakow
llakow asked
on
515 Views
Last Modified: 2013-12-13
I have a textarea input field on a form where users can either type content manually or paste in lists from notepad or columns or rows in a spreadsheet.  In Firefox, it works perfectly, in IE7 and 8 the pasted information is truncated after the first carriage return if the source is columnar - it works properly if it is all on one line or in one row.

An example would be as follows.

If you copy the content of a Notepad file
Line1
Line2
Line3
...
and paste it into the filed in Firefox, you get
Line1 Line2 Line3 ....     which then processes properly

If you paste the same content into IE, your get
Line1

and nothing more.

I need to find a way to accommodate columnar content from Notepad and spreadsheets in both environments (and Safari as well, although i haven't tested it there yet) since users will be deriving lists from a variety of sources and using notepad or a spreadsheet as a pre-processor to get the list items into the textarea.
The only Javascript on the page checks that the field isn't empty onsubmit.
The code snippet uses style to format the textarea, but I have tried rows and columns with no effect.
<td><div align="left">
                 <input name="long" type="textarea" id="long" style="width: 500px; height: 60px" value="" class="field2"/>
              </div></td>

Open in new window

Comment
Watch Question

Most Valuable Expert 2011
Author of the Year 2014

Commented:
Consider using TinyMCE for your textarea processor.  It is not perfect, but it can handle this situation pretty well.

http://tinymce.moxiecode.com/

HTH, ~Ray

Author

Commented:
Ray
Looks like a great tool, but unless I am missing something, it will impose another level of technophobe / computer interaction on the intended user base.
The users are generating lists of stock symbols they wish to track from a variety of sources that will allow them to create either csv or txt files as downloads.  I need to find a way for them to simply open the file with the appropriate program (a spreadsheet for csv and Notepad for txt, select all, copy and then paste into the text box.
Trying to get most of them to learn additional controls for each textarea they need to input will discourage many from using the system.

Author

Commented:
It occurs to me that a javascript function using onchange to trigger a parser to strip the offending non printing characters from the input, replacing them with spaces, might be a possible solution, but finding and replacing nonprinting characters in a string is beyond my limited javascript skills.

Commented:
paste your code here as we'll need to see the javascript to sort out that for you
or a url to the site so we can view source

Author

Commented:
Hmmm...Paste which code here?
Right now, the only code is the input textarea code listed in the initial question.
The javascript checkFields function I referred to is unrelated to this issue - it just checks that the required input fields aren't null when the form is submitted.
If you want to view the page on the actual site, you'll need to register at symbolsifter.com, login, select track stocks, and then create a list.
The code is about as basic as you can get - a simple html input form.
Do it in Firefox and it works perfectly.  Do it in IE and all you get is the first line
WFLong.txt

Commented:
I use spry text area's as I use cs4 and they work fine so if your using cs4 use a spry textarea

Author

Commented:
I'm not using cs4 - but I am curious what attributes cs4 can add to a textarea input field on a form so that a browser will treat it differently?
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.