JSFiddle - React, Tailwind, and code Playground

HTML

<form method="post"  action="">

<input type="text" name="txt" id="myinput" />

<p id="fmsg"></p>

<input type="submit" name="sub" />

</form>

JavaScript

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

var output = document.getElementById("fmsg");

function check(){
    var val = this.value;
    if(isNumber(val)){
        output.innerHTML = '<strong>' + val + ' is a number </strong>';
        this.maxLength = 14;
    }else{
        output.innerHTML = '<em>' + val + ' is not a number </em>';
        this.maxLength = 11;
        
    }

}

var inp = document.getElementById('myinput');
inp.onkeyup = check;