You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Abhimanyu Koul <ab...@fineng.com> on 2006/06/21 12:18:14 UTC

textarea

how can i set the maximum number of chars in a textarea. i can only set columns and rows.

Regards,
Abhimanyu Koul
FinEng Solutions (P)  Ltd.
Mobile : +91 9819510090

Re: textarea

Posted by Truong Xuan Tinh <ti...@pyramid-consulting.com>.
You have to write a javascript function to check in the following event:
onFocus, onChange and onKeyUp of the textarea.
Regards,

Abhimanyu Koul wrote:
> how can i set the maximum number of chars in a textarea. i can only set columns and rows.
>
> Regards,
> Abhimanyu Koul
> FinEng Solutions (P)  Ltd.
> Mobile : +91 9819510090
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: textarea

Posted by Bart Busschots <ba...@cs.nuim.ie>.
Abhimanyu Koul wrote:
> how can i set the maximum number of chars in a textarea. i can only set columns and rows.
>
> Regards,
> Abhimanyu Koul
> FinEng Solutions (P)  Ltd.
> Mobile : +91 9819510090
>
>   
The only way to do this would be with JavaScript. You'd do something 
like this:

<textarea name="blah" cols="20" rows="5" onchange="checkLength(this, 50)">
</textarea>
<script type="text/javascript">
function checkLength(ta, maxLen){
  if(ta.value.length>maxLen){
    window.alert("This text area may only contain " + maxLen + " 
characters, you tried to enter " + ta.value.length);
  }
}
</script>

HTH

Bart.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: textarea

Posted by "Miller, Andy" <Mi...@butte.edu>.
You will also need to do server side validation if you are attempting to
insert/update into a database (i.e., your users may have javascript
disabled in which case a javascript test alone will not be sufficient).
a

Andy Miller
IS Designer
Butte College
530.895.2946

-----Original Message-----
From: Mukta [mailto:mukta@amsoft.net] 
Sent: Wednesday, June 21, 2006 9:42 PM
To: 'Struts Users Mailing List'
Subject: RE: textarea

Use following javascript function to limit the number of characters to
255
in a textbox:

function checkLength(name)
{
	var textBox = document.getElementsByName(name)[0].value;
	if (textBox.length>255)
	{
		document.getElementsByName(name)[0].value =
textBox.substring(0,255);
	}
}

And call this function on 

onkeyup="checkLength('textareaName');"
onmouseout="checkLength('textareaName');"




-----Original Message-----
From: Abhimanyu Koul [mailto:abhimanyu_koul@fineng.com] 
Sent: Wednesday, June 21, 2006 3:48 PM
To: Struts Mailing list
Subject: textarea

how can i set the maximum number of chars in a textarea. i can only set
columns and rows.

Regards,
Abhimanyu Koul
FinEng Solutions (P)  Ltd.
Mobile : +91 9819510090



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: textarea

Posted by Mukta <mu...@amsoft.net>.
Sorry I mean "textarea". I have mistakenly written "textbox" for "textarea".
Anyways, its just a variable name. Doesn't affect the functionality.


-----Original Message-----
From: Mukta [mailto:mukta@amsoft.net] 
Sent: Thursday, June 22, 2006 10:12 AM
To: 'Struts Users Mailing List'
Subject: RE: textarea

Use following javascript function to limit the number of characters to 255
in a textbox:

function checkLength(name)
{
	var textBox = document.getElementsByName(name)[0].value;
	if (textBox.length>255)
	{
		document.getElementsByName(name)[0].value =
textBox.substring(0,255);
	}
}

And call this function on 

onkeyup="checkLength('textareaName');"
onmouseout="checkLength('textareaName');"




-----Original Message-----
From: Abhimanyu Koul [mailto:abhimanyu_koul@fineng.com] 
Sent: Wednesday, June 21, 2006 3:48 PM
To: Struts Mailing list
Subject: textarea

how can i set the maximum number of chars in a textarea. i can only set
columns and rows.

Regards,
Abhimanyu Koul
FinEng Solutions (P)  Ltd.
Mobile : +91 9819510090



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: textarea

Posted by Mukta <mu...@amsoft.net>.
Use following javascript function to limit the number of characters to 255
in a textbox:

function checkLength(name)
{
	var textBox = document.getElementsByName(name)[0].value;
	if (textBox.length>255)
	{
		document.getElementsByName(name)[0].value =
textBox.substring(0,255);
	}
}

And call this function on 

onkeyup="checkLength('textareaName');"
onmouseout="checkLength('textareaName');"




-----Original Message-----
From: Abhimanyu Koul [mailto:abhimanyu_koul@fineng.com] 
Sent: Wednesday, June 21, 2006 3:48 PM
To: Struts Mailing list
Subject: textarea

how can i set the maximum number of chars in a textarea. i can only set
columns and rows.

Regards,
Abhimanyu Koul
FinEng Solutions (P)  Ltd.
Mobile : +91 9819510090



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org