views:

31

answers:

1

Hi

I have this function in javascript file which works perfectly fine in Firefox / Chrome but for some reason throwing 'Object doesn't support this property or method' error on IE 8 .

Any ideas how should I rewrite the function so it is working in all sort of IEs?

validateStep1: function () {

     var digitOnly=/^\d/;
     var result =  $('#Step1DropDownIndustry option:selected').val() == 0 || 
                   $('#Step1DropDownIndustry option:selected').val() == 0 ||
                   $('#Step1Annual').val().trim() == '' || 
                   $('#Step1Annual').val().search(digitOnly) == -1
     return result;
},

Cheers

+1  A: 

A native .trim() function for strings isn't available in IE<9, use $.trim() like this instead:

$.trim($('#Step1Annual').val())

This gets a revision/optimization in jQuery 1.5, it'll use the native method if it's there, and fall back to a regex if not.

Nick Craver
works like a charm. Thanks Nick !
uiru