Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

check for alphabetic string in javascript

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

PREVIOUS NEXT
Code Example
Javascript :: invalid time value react datepicker 
Javascript :: read csv file in javascript 
Javascript :: return random rows sqlite 
Javascript :: Parcel, how to fix the `regeneratorRuntime is not defined` error 
Javascript :: how to send static file in express 
Javascript :: toggle hidden attribute javascript 
Javascript :: jquery alert design 
Javascript :: convert object to boolean javascript 
Javascript :: javascript check if two keys are pressed 
Javascript :: react delete button onclick 
Javascript :: date.tolocaledatestring is not a function 
Javascript :: newtonsoft.json string to object 
Javascript :: vue fetch api 
Javascript :: convertir seconde 
Javascript :: javascript check if date object 
Javascript :: update angular materia; 
Javascript :: set time to zero in js date 
Javascript :: javascript sample list 
Javascript :: serialization and deserialization in javascript 
Javascript :: ajax post body parameters 
Javascript :: jquery get all checkbox checked 
Javascript :: json rename key 
Javascript :: speedtest-net node.js 
Javascript :: buffer from base64 
Javascript :: javascript tofixed 
Javascript :: javascript check if object property exists 
Javascript :: dynamically add script code to page 
Javascript :: how to loop through array of numbers in javascript 
Javascript :: can filter be used on objects in javascript 
Javascript :: jquery each loop 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =