irregularexpressions
irregularexpressions

Reputation: 262

"Use Strict" breaking Javascript function - Why?

Adding "use strict" to this function is breaking it. Specifically the inputs I am trying to un-disable are remaining disabled in strict mode. csc_popup_in() and csc_popup_out() functions are defined prior to this one. Thanks in advance for any input.

function show_cc(){
    document.getElementById('cc_fade').className='none';

    var cc_inps = document.getElementById('cc_fade').getElementsByTagName('input');
    for(i=0 ; i<cc_inps.length ; i++){
        cc_inps[i].disabled=false;
    }

    document.getElementById('csclnk').onmouseover = function(){csc_popup_in();};
    document.getElementById('csclnk').onmouseout = function(){csc_popup_out();};

    if(document.getElementById('amex').checked){
        document.getElementById('cc_num').maxLength = 15;
        document.getElementById('cc_csc').maxLength = 4;
    } else {
        document.getElementById('cc_num').maxLength = 16;
        document.getElementById('cc_csc').maxLength = 3;
    }
}

Upvotes: 2

Views: 381

Answers (1)

Pointy
Pointy

Reputation: 413717

You forgot to declare "i" with var!!!

Upvotes: 4

Related Questions