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!

textarea question, I know there's lots of reference but this is good

Status
Not open for further replies.

Maim

Programmer
Jun 25, 1999
106
CA
ok this is the situation...
I'm able to limit the number of charcters entered into a textarea with some javascript and a couple of event calls. This takes care of when typing, pasting with ctrl+v and pasting with the right-mouseclick.

Only one option remains... edit->paste :(

Here's my script ...
Code:
<script language=&quot;javascript&quot;>
function ValidateLength(oCtrl, lLength)
{//	Use with onKeyUp, onKeyDown and onMouseOut events.
//	This will prevent exceeding the length, when typing, pasting with keyboard or pasting with right-mouseclick
	if (oCtrl.value.length > lLength)
		oCtrl.value = oCtrl.value.substring(0, lLength);
}
</script>
[code]

and in the html...
[code]
<textarea style=&quot;width:290px&quot; name=&quot;comment_1&quot; onkeydown=&quot;ValidateLength(this, 10)&quot; onkeyup=&quot;ValidateLength(this, 10)&quot; onmouseout=&quot;ValidateLength(this, 10)&quot;>
[code]

Anyone have a suggestion? Anyone? Anyone?
 -----------------------------------
&quot;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.&quot; - Rich Cook
 
onchange=&quot;...&quot;
or
ondatachange=&quot;...&quot;
I do not remember well, just try them yourself.
Coding is the worst thing I had done.
 
I did, I thought I had something with onPaste but that didn't work either. -----------------------------------
&quot;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.&quot; - Rich Cook
 
What's the purpose of not allowing them to paste characters within this textfield?

sulfericacid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top