TextArea Count and Max Length ( Displaying ) on Keyup
<html>
<head>
<script type="text/javascript">
function textCounter(textarea, counterID, maxLen) {
cnt = document.getElementById(counterID);
if (textarea.value.length > maxLen){
textarea.value = textarea.value.substring(0,maxLen);
}
cnt.innerHTML = maxLen - textarea.value.length;
}
</script></head>
<body>
<textarea name="mytext" id="mytext" style="width:99%; height:100px;" value="" onkeyup="textCounter
(this,'count_display',255);" onBlur="textCounter(this,'count_display',255);"></textarea>
<span id="count_display">255</span>
a
</span>
</body>
</html>
Comments
Post a Comment