JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="maxlength">
<input type="submit" id="btn">
JavaScript
$("#btn").click( function () {
var x = $("#maxlength").val();
if (x.length > 7 || x.length < 5) {
alert("Слишком длинный или короткий никнейм");
}
});