Character Counting Remaining on Textarea

text area with maxlenght that feeds how many characters the user has remaining

by TheOrdinaryGeek

HTML

<textarea cols="50" name="reason_text" id="reason_text" placeholder="Reason for requesting access (Please give full details)*" rows="5"></textarea>
<div id="textarea_feedback"></div>

JavaScript

$(document).ready(function() {
  var text_max = 99;
  $('#textarea_feedback').html(text_max + ' characters remaining');
  $("#reason_text").on('keydown keypress keyup', function() {
    var text_length = $('#reason_text').val().length;
    var text_remaining = text_max - text_length;
    $('#textarea_feedback').html(text_remaining + ' characters remaining');
  });
});