Friday, July 18, 2008

String Index using string[index] or string.charAt(index)

I found this issue today on string index of javascript for IE 7.

It seems like IE7 does't like String[index] at all, but it works with string.charAt(indext).


Try this out:

function memberlink_txtchange(id){
var value = $('#'+id).val();
var int_var;
var new_var = '';
for(var i = 0; i < value.length; i++){
if(checknumber(value.charAt(i))){
new_var += value.charAt(i);
}
}

$('#'+id).val(new_var);
return true;
}

1 comment:

craig said...

thanks a ton, this one saved me a lot of headache for IE6 debugging.