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