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