check string is whitespaace or not js code example Example: check whitespace in javascript if (/\s/.test(str)) { // It has any kind of whitespace }