check for all white space in string javascript code example
Example 1: javascript remove all whitespaces
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
Example 2: check whitespace in javascript
if (/\s/.test(str)) {
// It has any kind of whitespace
}