Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check if a string has only alphabets in javascript

if (!/[^a-zA-Z]/.test(word))
Comment

checking if a character is an alphabet in js

function isLetter(str) {
  return str.length === 1 && str.match(/[a-z]/i);
}
Comment

how to check if a string is alphabetic in javascript

function isAlphaOrParen(str) {
  return /^[a-zA-Z()]+$/.test(str);
}

/*/^[a-zA-Z()]*$/ - also returns true for an empty string
/^[a-zA-Z()]$/ - only returns true for single characters.
/^[a-zA-Z() ]+$/ - also allows spaces*/
//better regEX to include question marks too
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript change border radius 
Javascript :: js push params to url 
Javascript :: js add params to url 
Javascript :: change image src jquery 
Javascript :: how to do a classname variable and string react 
Javascript :: react-native init AwesomeProject change port 
Javascript :: sh 1 nodemon not found heroku 
Javascript :: how to replace non alpha numeric characters in javascript 
Javascript :: how much html and css before javascript 
Javascript :: convert arguments to array javascript 
Javascript :: how to create a react app in current folder 
Javascript :: javascript save result to file 
Javascript :: nextelementsibling js 
Javascript :: fetch url in javascript 
Javascript :: change elements class javascript 
Javascript :: canvas round rectangle 
Javascript :: vue check if list is empty 
Javascript :: jquery to another page 
Javascript :: upsert mongoose 
Javascript :: character to ascii in js 
Javascript :: how to set disabled flag formgroup angular 
Javascript :: datatable desc active 
Javascript :: chart js laravel mix 
Javascript :: getServerSideProps cookie 
Javascript :: how to update all node libraries 
Javascript :: javascript lowercase string except first letter of every word 
Javascript :: ignore node_modules 
Javascript :: react native get current time 
Javascript :: how to create a .js file in windows command prompt code 
Javascript :: draw a rectangle on canvas on pointermove 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =