Javascript behaving weirdly
<p>the following function does not work as I thought it should have. For some reason, the loop breaks whenever one the the validate function returns false. Why is that?</p>

<p>Here is my code :</p>

<pre><code>function validateGroup(input) {
    if (!input.value.match(/^[0-9]{0,2}$/)) {
        $(input).addClass("invalidField");
        return false;
    }
    $(input).removeClass("invalidField");
    return true;
}

function validateClass(input) {
    if (!input.value.match(/^[a-zA-Z0-9-]{0,9}$/)) {
        $(input).addClass("invalidField");
        return false;
    }
    $(input).removeClass("invalidField");
    return true;    
}

function validateData() {
    var rows = document.getElementsByTagName("tbody")[0].getElementsByTagName("tr");

    var valid = true;

    for (var i = 0, arrayLength = rows.length; i &lt; arrayLength; ++i) {
        valid = valid &amp;&amp; validateClass(rows[i].getElementsByTagName("input")[0]);
        valid = valid &amp;&amp; validateGroup(rows[i].getElementsByTagName("input")[1]);
        valid = valid &amp;&amp; validateGroup(rows[i].getElementsByTagName("input")[2]);     
    }
    return valid;
}
</code></pre>

<p>Thanks a lot!</p>
