JSFiddle - React, Tailwind, and code Playground

HTML

<input id="txtbox" /><br/>
<span id="charCount"></span>

JavaScript

$('#txtbox').keypress(function() {
    var max = 500;
    var textLen = $(this).val().length;
    var textLeft = max - textLen;
    $('#charCount').text(
        textLeft + ' character' + (textLeft == 1 ? '' : 's') + ' left'
    );
});
$('#txtbox').keypress();