JustinWDev of Archived Theme Support
10/29/2014 - 4:00 PM

Disallow special characters from input fields. Example with cart note.

Disallow special characters from input fields. Example with cart note.

$('[name="note"]').bind('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;
  }
});