I'm creating a pay request form where the user will select how they want to be paid for overtime worked. The two choices are 'pay' (user receives extra pay in their paycheck), or 'time' (user receives compensatory time-off to be taken at a later date).

I've created a radio button input for the user to select one or the other. I wrote a validation to make sure one button is selected and it works fine in my test program, but when I bring it into the code for this project, the code doesn't run. as far as I can see, there are no differences between my test program and the project.

I'm trying to use a simpler boolean and would like to stick with this option rather than a for-loop or using JQuery if possible.

here is the relevant portion of html:

```
<form class="oTcard" name="otCard" onSubmit="return submitCard()" method="post">
<div>
    <label>
        <span>request</span>
            <div style="display:block">
                <input class="radio" type="radio" id="timePay" name="timePay" value="0" ><span>time</span>
                <input class="radio" type="radio" id="timePay" name="timePay" value="1"><span>pay</span>
            </div>
     </label>
</div>
<input type="submit" id="submit" value="submit">
</form>

```

here is the relevant portion of the javascript:

```
function submitCard (form) {
    errorString = "";
    if((form.timePay[0].checked == false) && (form.timePay[1].checked == false)) {
        alert("please choose either time or pay");
        timePay[0].focus();
        return false;
    }
    if(errorString = "") {
        form.submit()
    }
}

```

Edit to add the following:

Cyril DD's answer pointed me in the right direction.
I changed the ID's of the radio buttons to be unique to each button.
The HTML now reads:

```
<form class="oTcard" name="otCard" onSubmit="return submitCard()" method="post">
<div>
    <label>
        <span>request</span>
            <div>
                <input class="radio" type="radio" id="selectTime" name="timePay" value="0"><span>time</span>
                <input class="radio" type="radio" id="selectPay" name="timePay" value="1"><span>pay</span>
            </div>
     </label>
</div>
<input type="submit" id="submit" value="submit">
</form>

```

I then defined each button as a separate variable rather than collectively as "timePay" as I had before and changed the javascript as follows:

```
if((selectTime.checked == false) && (selectPay.checked == false)) {
    alert("please choose either time or pay");
    selectTime.focus();
    return false;
}

```