Onclick with check box
<p>I have a check box which calls a js function like so :</p>

<pre><code>&lt;input type="checkbox" onclick="return validate('tos')" value="1" name="tos"/&gt;
</code></pre>

<p>But i am having a problem with the JS detecting when it is infact unticked it seems to always return true.</p>

<p>This is how i have my script:</p>

<pre><code>function validate(type){

    var x = document.getElementById("reg"); //get array of elements in form "reg"
    var input = x.elements[4].value; //[4] = checkbox

    if(input){
        alert('ticked');    
    } else {
        alert('not ticked');    
    }
}
</code></pre>

<p>But it always returns ticked, even if the user clicks it when it was already ticked (which i thought would mean it was not the value of 1 anymore)... is there a way i can fix that in JS ? </p>
