JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="myInput"></textarea> <br>
Counter: <span id="charCount"></span>
<div id="message"><!--put message here--></div>
CSS
textarea { width:300px; height:200px; }
JavaScript
$('#myInput').keyup(function() {
var len = this.value.length ;
$('#charCount').text(len);
var creditCount = 158;
if( len > creditCount ){
var credits = Math.floor(len / creditCount );
$('#message').html('We will deduct '+ credits + ' credit from your account;' )
}
});