Hizzy
Hizzy

Reputation: 879

$.trim() jQuery not working in IE

I am having issues with using $.trim() in IE it works just fine in firefox. Does anyone see any reason this would fail. Thank you.

$('#GuestEmailAddress').on('blur', function () {                
            var $inputValue = $(this).val();
            $.trim($inputValue);
            $(this).val($inputValue); 
        });

Upvotes: 0

Views: 551

Answers (2)

rfornal
rfornal

Reputation: 5122

Try changing the line ...

$.trim($inputValue);

... to ...

$inputValue = $.trim($inputValue);

The first does not change the $inputValue, it simply returns the new string which in the second set of code I am assigning to a value that can then be used later in the code.

Upvotes: 1

nril
nril

Reputation: 568

Change your code as follows...

delete:

$.trim($inputValue);

change:

var $inputValue = $(this).val();

to:

var $inputValue = $(this).val().trim();

Upvotes: 1

Related Questions