Possible Duplicate:
How to limit number of characters per line in text area to a fixed value.
hello Friends,
I have a textarea field in my view.
I need to set per line 72 characters length.
that is user is entering more than 72 chracter per line I need go to next line.
How to set these limits using jquery or javascript?
Thanks
In some cases, there is a need of putting a limit on the size of characters that can be typed in a textarea. So in that case, we can use maxlength attribute to control the number of characters entered in a textarea.
The HTML <Textarea>maxlength attribute is used to specify the maximum number of characters enters into the Textarea element. Attribute Value: number: It contains single value number which allows the maximum number of character in Textarea element. Its default value is 524288.
To ensure line lengths don't exceed 80 characters, the CSS max-width property can be set using font-relative lengths of around 70ch or 34em (note that this value will need to be adjusted slightly up or down depending on the font used).
This is not standard, but it works in many browsers, test it.
http://www.htmlcodetutorial.com/forms/_TEXTAREA_WRAP.html
<TEXTAREA NAME="HARD" COLS="72" ROWS="5" WRAP="HARD">
Setting wrap to hard makes it send new lines to the server. Setting it to soft only breaks it visually.
No need to use javascript for this. There is a HTML attribute built into the <textarea>
tag.
See some documentation here.
example for your use
<TEXTAREA NAME="HARD" COLS=72 ROWS=5 WRAP=HARD></TEXTAREA>
Using a HARD
Wrap actually sets carriage returns when the line is wrapped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With