in reply to Re: Tidying up textarea fields
in thread Tidying up textarea fields

(Actually, I think web browsers do not send \r characters in forms. I could be wrong.)

False. Not all browsers send \r, but some do (most notably Windows-based MSIE (not sure about Mac)). This can be a real pain for first time textarea handlers because (of course) \r isn't the same thing as \n, but it looks the same.

Replies are listed 'Best First'.
Re: Tidying up textarea fields
by antjock (Novice) on Dec 15, 2000 at 00:51 UTC

    This is exactly what I was after, or exactly the kind of info I was trying to find out.

    I guess I should have been a little clearer about what my purposes are, and why I'm 'cleaning up' the textarea in the first place.

    Firstly, the cgi is intended to be a general purpose script to process surveys we do on our intranet. The cgi allows you to pass in some parameters to configure it (such as the delimiter to use in the output file, the name of the output file, etc.). The form data is 'encoded' and both written to an output file and sent in an email to the person administering the survey.

    Now this 'encoding' or cleaning up is mainly meant for the textarea, where people tend to wax philosophic and ramble on for many lines. I need to be able to capture that in a flat file (typically pipe delimited, but I tried to make it so that it was flexible/extensible) and keep it in a format that is reasonably sane.

    I don't want to lose the formatting, so that's kind of what I was originally trying to get at, "How do you deal with the data you get back from a textarea from a form?" Do you just write it out, or do you do anything to it to remove all the nefarious tabs, newlines, microsoft spew, weird browser cruft, etc?

    By the way, I am using CGI.pm to bring all the form data, but CGI doesn't really give you anyway to 'clean' it once you've got it. That's what we got Perl for. :->

    I'm starting to mess with CGI::Validate, but that doesn't seem to address this directly, really.

    Anyway, thanks alot for the feedback so far.

    This whole thing has also got me thinking why the textarea on this form is not wrap="virtual"... I hate when the textareas are not wrapped and the lines go on and on and on, but the people who made perlmonks are smart, they had to have done this for a reason...