Charater count

<script type=’text/javascript’>
var maxLength=250;
function charLimit(el) {
    if (el.value.length > maxLength) return false;
    return true;
}
function characterCount(el) {
    var charCount = document.getElementById(‘charCount’);
    if (el.value.length > maxLength) el.value = el.value.substring(0,maxLength);
    if (charCount) charCount.innerHTML = maxLength – el.value.length;
    return true;
}
</script>

<form>
    <textarea onKeyPress=”return charLimit(this)” onKeyUp=”return characterCount(this)”  rows=”8″ cols=”40″></textarea>
</form>
<p><strong><span id=”charCount”>250</span></strong> more characters available.</p>

Advertisements

One thought on “Charater count”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s