Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim is not working in IE7

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.

like image 985
Arun Rana Avatar asked Feb 01 '12 05:02

Arun Rana


2 Answers

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())
like image 80
user1106925 Avatar answered Nov 04 '22 16:11

user1106925


The val() method doesn't always return a string. If the selected item is an option it can return an array which doesn't support trim. Have you checked the type of val() to see if it's actually a string?

Note: As others have pointed out trim isn't supported on IE7 even if this is a string. Need at least IE9.

like image 1
JaredPar Avatar answered Nov 04 '22 18:11

JaredPar