|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Limit size of textarea
Does anyone know of a way to limit the number of characters in a text area?
I have a form in a php page. The page writes the information of the form into a file. IF too much text gets entered, my display page gets messes up. I want to be able to limit the text entered in the textarea. Is this even possible? |
|
#2
|
|||
|
|||
|
RE: Limit size of textarea
here is some code that will prevent a user from entering more than the specified number of characters in a textarea.
<script language="javascript"> var text1; function checklength(i) { var txt; txt=document.form.textarea1.value; n=txt.length; if (n>i) //i is the maxlength of textarea which we have set to 50 { alert('Text overflow'); document.form.textarea1.value=text1; return; } text1=document.form.textarea1.value; } </script> <body> <form name="form"> <textarea name="textarea1" onkeydown="checklength(50)"></textarea> </form> </body> by changing the number in the checklength() function call, you can specify any length you like |
|
#3
|
|||
|
|||
|
RE: Limit size of textarea
Thank you! It worked.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Limit size of textarea |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|