Main Page
 The gatekeeper of reality is
 quantified imagination.

Stay notified when site changes by adding your email address:

Your Email:

Bookmark and Share
Email Notification
jsTextCountRemaining [Go Back]
It can be very helpful to an individual completing a text block if they know how many characters are left. The demo below shows how you can do this:


Remaining: 20

Source Code:
<script language="javascript">
<!--
function txtBoxCharacters(target, txtMax, report) {
var txtSize = document.getElementById(target).value.length;
if (txtSize > txtMax) {
		       var txtData = document.getElementById(target).value;
		       txtData = txtData.substr(0, txtMax);
		       document.getElementById(target).value = txtData;
		      }
var reserve = txtMax - document.getElementById(target).value.length;
if (navigator.userAgent.toLowerCase().indexOf("msie") > -1) { document.getElementById(report).innerText = reserve; }
else { document.getElementById(report).textContent = reserve; }
}
//-->
</script>

HTML Code:
<textarea name="test" id="test" cols="50" rows="3" wrap="on" onkeyup="txtBoxCharacters('test', 20, 'remain');"></textarea>
<br />Remaining: <span id="remain">20</span>
About Joe