JSFiddle - React, Tailwind, and code Playground

by Varun Krishna P

HTML

<input type="text" id="txtname" name="txtname">

JavaScript

$("#txtname").on('keypress',function(){   
    if($(this).val().length>20){
        alert("error message");
        return false;
    }
    
});