Possible Duplicate:
How can i check if a radio button is selected in javascript?
I am trying to implement client side validation on radio buttons. For example, pay status is either paid or unpaid. If they do not select any, I want it to say "Select your pay status." If either is checked, it will already display in a label through server side validation.
<script language="javascript">
$document.ready function() {
valButton = function(btn) {
for (var i=btn.length-1; i > -1; i--) {
if (btn[i].checked) return btn[i].value;
}
return null;
}
if (null === valButton (document.getElementsByName (document.getElementById('rdoPaid').name)) {
message('Select a pay status.');
}
});
</script>
Pay Status
<input ID="rdoPaid" Text="Paid" />
<br />
<input ID="rdoUnpaid" Text="Unpaid" />
Instead of input, I am really using asp:RadioButton.
This is what I was trying. Can anyone help me getting this to work properly?