[ic] Stripping CR/LF from form input

Mike Heins mike at perusion.com
Sun Apr 23 11:19:10 EDT 2006


Quoting DB (DB at M-and-D.com):
> >> # filter to strip "returns" from coments
> >> CodeDef no_crlf Filter
> >> CodeDef titlecase Routine <<EOR
> >>  sub {
> >>  my $val = shift;
> >>  $val =~ s/[\x00-\x1F]+/ /g;
> > 
> 
> > $val =~ s/[\r\n]+/ /g;
> 
> > 
> >>  return $val;
> >>  }
> >> EOR
> > 
> > You realise that you're adding in linefeeds here (one above the data and 
> > one below)?  Try it as one line instead.
> > 
> >> <TEXTAREA NAME="notes">
> >> [filter no_crlf]
> >> [data table=transactions col=notes key=[loop-code]]
> >> [/filter]
> >> </TEXTAREA>
> > 
> > Peter
> 
> 
> Hi - thanks for the reply. I tried changing the filter to your version,
> and doing the filter all on one line (actually it was on one line
> already but I posted that way because of the way it was wrapping). It
> still does not do the job - again I can make updates to the field but
> the carriage returns are not removed. I must be missing something?
> 
> The odd part is that if I just display the notes field on the form, the
> carriage returns don't appear. But if I do a
> 
> select notes from transactions where order_number=1000
> 
> they are indeed present. My life would be improved if I could get rid of
> these!
> 

Are you sure you aren't just seeing the wrap of the textarea? 

You have to do something like:

	catalog.cfg

	Filter  notes  no_crlf

or

	<input type=hidden name="mv_data_filter" value="no_crlf">

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Being against torture ought to be sort of a bipartisan thing.
-- Karl Lehenbauer


More information about the interchange-users mailing list