JSFiddle - React, Tailwind, and code Playground

by Ketan Patel

HTML

Number : <input type="text" name="quantity" id="billing_postcode" /><br>
Address : <input type="text" name="quantity" id="billing_address_1" /><br>
City : <input type="text" name="quantity" id="billing_postcode_1" /><br>

CSS

#errmsg
{
color: red;
}

JavaScript

$(document).ready(function () {
  $('input').on('keypress', function (event) {
    var regex = new RegExp("^[a-zA-Z0-9 !@#$%&*()]+$");
    var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
    if (!regex.test(key)) {
       event.preventDefault();
       return false;
    }
});
  
});