JSFiddle - React, Tailwind, and code Playground
HTML
<input maxlength="3" id="myinput1" /><input maxlength="3" id="myinput2" />
JavaScript
$( "#myinput1" ).on('input', function() {
if ($(this).val().length>3) {
alert('you have reached a limit of 3');
}
});
$( "#myinput2" ).on('input', function() {
if ($(this).val().length>3) {
alert('you have reached a limit of 3');
}
});