JSFiddle - React, Tailwind, and code Playground

by soyuka

HTML

<input type="text" id="only-text" />

JavaScript

$("#only-text").on('keyup', function(e) {
    var val = $(this).val();
   if (val.match(/[^a-zA-Z]/g)) {
       $(this).val(val.replace(/[^a-zA-Z]/g, ''));
   }
});