JSFiddle - React, Tailwind, and code Playground

by bryandowning

HTML

<input type="text">

JavaScript

$('input').on('input', function(){

    var value = $(this).val();
    
    var newVal = value.replace(/[^0-9+\-]/g, '');

    $(this).val( newVal );
    
    console.log('Value:', value, 'New Value:', newVal);

});