JavaScript hanya mengizinkan karakter numerik

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