JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text">
JavaScript
var oldValue = $( "input[type='text']" ).val();
var limit = 10;
$( "input[type='text']" ).on('keydown',function(e) {
oldValue = $( this ).val();
})
$( "input[type='text']" ).on('input propertychange',function(e) {
newValue = $(this).val();
if(newValue.length > limit){
$(this).val(oldValue)
}
});