jcadima
1/3/2016 - 1:36 AM

Display Character count

Display Character count

HTML:
  	<form action="" method="post">
  	  <input id="string" type="text" name="string" value="<?php if(isset($string)) echo "$string";  ?>">
  	  <div id="string_feedback"></div>
  	  <input type="submit" value="submit">
  	</form>

JS:
<script>
$(document).ready(function() {
    $('#string').keyup(function() {
        var text_length = $('#string').val().length;
        // here we update the div with the keyup event
        $('#string_feedback').html(text_length + ' characters ');
    });
});
</script>