Answers for "check if a string is empty or contains whitespaces only in js"

2

javascript check if blank space

function isEmptyOrSpaces(str){
    return str === null || str.match(/^ *$/) !== null;
}
Posted by: Guest on July-01-2021
0

regex for check if string is only empty or whitespace javascript

//empty string or white space
function hasWhiteSpace(value) {
  return /^\s*$/.test(value);
}

// empty string or string with white space 
function hasWhiteSpace(value) {
  return /^$|\s+/.test(value);
 }
Posted by: Guest on September-09-2021

Code answers related to "check if a string is empty or contains whitespaces only in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language