JSFiddle - React, Tailwind, and code Playground

by no2don

HTML

<script src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
      <input class="form-control"  onKeypress="return custKeypress(event);" 
      onKeyUp="custKeyUp(event)"
      />

JavaScript

function custKeyUp(e) {
  	e.target.value=e.target.value.toUpperCase();
  
 }

   
   function custKeypress(e) {

            var allowedChars = /^[a-z\d -]+$/i;
            
            var str = String.fromCharCode(e.charCode || e.which);
						
            if (allowedChars.test(str)) {
                e.target.value=e.target.value.toUpperCase();
                return true;
              
            }

           e.preventDefault();
            return false;
 }