check if input contains space code example Example: check if input have word not space only if (/\s/.test(str)) { // It has any kind of whitespace }