remove the white space while char count in jquery code example Example: trim space in jquery var str = " Hello World! "; alert(str.trim());