Page 1 of 1

[Forms] Limit lines instead of characters (updated problem!)

Posted: Sat Jul 29, 2006 5:51 am
by thiscatis
Hi!

Is there a way that you can limit the number of lines of text submitted through a form instead of the characters?

(no javascript pls)

Posted: Sat Jul 29, 2006 6:46 am
by litebearer
Hmmm

I suppose you could check the variable for the number of new lines and either send back to user to re-enter or simply truncate the variable to three lines.

w/o javascript this would need to be done server-side (not sure how ajax works but it may be possible to us eit also)

Lite...

Posted: Sat Jul 29, 2006 7:12 am
by Ollie Saunders
see:

Code: Select all

count_chars();
wordwrap();
explode() and count();

Posted: Tue Aug 01, 2006 10:54 am
by thiscatis
ole wrote:see:

Code: Select all

count_chars();
wordwrap();
explode() and count();
could you be more precise?

The problem:
The input is done bya wysiwyg editor, when you hit enter it's gives <p align = left> text </p> as a new line.
This messes up my layout.
I already tried to do it with


Code: Select all

$text = substr($contenta,0,250);
$text = ereg_replace( "<p align="left">", " ", $text);
$text = ereg_replace( "</p>", "<br>", $text);
but it looks like it won't count spaces as a character..

anyone?

Posted: Tue Aug 01, 2006 11:29 am
by thiscatis
maybe another solution:
Is there a way to limit the rows of an textarea?

Posted: Tue Aug 01, 2006 11:30 am
by Ollie Saunders
try

Code: Select all

$text = substr($contenta, 0, 250);
$text = str_replace('<p align="left">', '', $text);
$text = str_replace('</p>', '<br /><br />', $text);