space in string using if in jquery code example Example: space in string using if in jquery if(key.indexOf(' ') >= 0){ alert(); }