$('#MyTextInput').on('propertychange input', function () { let result = $(this).val().replace(/[^d]+/g, ''); $(this).val(result); });