Skip to content

Instantly share code, notes, and snippets.

@tsbits
Last active August 29, 2015 14:02
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 tsbits/8ccd0927b0afbf2e04a2 to your computer and use it in GitHub Desktop.
Save tsbits/8ccd0927b0afbf2e04a2 to your computer and use it in GitHub Desktop.
Check if a string contains only letters
function checkAlpha(word) {
var newStr = word.replace(/(^\s+|\s+$)/g,'');
if (newStr.length > 0) {
if (/[^A-Za-zàáâãäåæçèéêëæìíîïñòóôõöøßùúûüÿÀÁÂÃÄÅÆÇÈÉÊËÆÌÍÎÏÑÒÓÔÕÖØßÙÚÛÜŸ \-']/.test(newStr)) return false;
else return true;
} else return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment