Skip to content

Instantly share code, notes, and snippets.

@carlossalas
Created January 10, 2014 18:33
Show Gist options
  • Save carlossalas/8359898 to your computer and use it in GitHub Desktop.
Save carlossalas/8359898 to your computer and use it in GitHub Desktop.
JS: Force Letter Only
jQuery.fn.ForceLettersOnly = function() {return this.each(function() {$(this).keydown(function(e) {var key = e.charCode || e.keyCode || 0; var letter = String.fromCharCode(key); return ((key < 48 || key > 57) && (key < 96 || key > 105) || !letter.match(/[^a-zA-Z]/g)); }); }); };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment