Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, In a textarea I want to limit the number of characters to be 3

Status
Not open for further replies.

rmittal

Programmer
Aug 8, 2000
8
US
Hi,
In a textarea I want to limit the number of characters to be 358. After 358 characters the user shouls not be able to type. Also, the initial value in a textarea should be '**' and the user should start writing after these 2 characters. So then the characters the user can type will be 356+"**". How do i do this??

Someone told me to use <input type=textarea maxlength=358 value=&quot;**&quot;>
But this does not work. It just shows a single text field. I want a textarea to be seen.
 
here is some code for you:

<html>
<script>
function test_onkeypress() {
var text = document.frmMain.test.value
if(text.length >= 358) {
alert(&quot;you have typed to many characters&quot;)
return false;
}
}
</script>
<body>
<form name=frmMain>
<textarea name=test rows=20 cols=50 onkeypress=&quot;return test_onkeypress()&quot;>**</textarea>
</form>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top