<input>
<textarea>
maxlength
<input type='text' maxlength='50' id='FirstName' /> <div id='FirstNameCharsLeft'></div>
/*------------------------------------------------------------------------------------------------*/ $(document).ready(function(){ setInterval("timerClick()", 300); }); /*------------------------------------------------------------------------------------------------*/ function timerClick(){ showCharsLeft('#FirstName', '#FirstNameCharsLeft'); } /*------------------------------------------------------------------------------------------------*/ function showCharsLeft(inputSelector, outputSelector) { var inputField = $(inputSelector); var maxLength = inputField.attr('maxlength'); if (maxLength != undefined) { var length = inputField.val().length; var charsLeft = maxLength - length; $(outputSelector).html(charsLeft + " character(s) left"); } } /*------------------------------------------------------------------------------------------------*/