JavaScript hanya mengizinkan karakter alfanumerik

$('#MyTextInput').on('propertychange input', function () {
  let result = $(this).val().replace(/[^0-9a-z]/gi, '');
  $(this).val(result);
});
Syntax Error