Skip to content

Instantly share code, notes, and snippets.

@bandicsongor
Created August 8, 2013 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bandicsongor/6184335 to your computer and use it in GitHub Desktop.
Save bandicsongor/6184335 to your computer and use it in GitHub Desktop.
can be used on textboxes to verify it the pressed key is a letter or not, usage: onkeypress = 'return isLetter(event)'
function isLetter(evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (charCode > 31 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122))
{
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment