Trim is not working in IE7

Arun Rana picture Arun Rana · Feb 1, 2012 · Viewed 7.9k times · Source

trim() javascript function not working in IE7 however it' working fine in all other version and all browser. what should be issue with IE7 or how i can resolve this?

$("#Email").val().trim()

IE7 gives error

Thanks in advance.

Answer

user1106925 picture user1106925 · Feb 1, 2012

IE doesn't support String.prototype.trim() until IE9.

It looks like you're using jQuery, so you can use $.trim() instead.

$.trim($("#Email").val())