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