Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation for Radio buttons

Status
Not open for further replies.

prakus

Programmer
Aug 4, 2003
19
US
I have the a FORM for rearranging some records (number of records is dynamic).

The code for the Form is :

<Form name='RearrangeSectionForm' Method='POST' Action='includes/updateSectionOrder.asp' onsubmit='return checkRadios(this);'>
<table width='90%' align='left'>
<tr><td width='20%' align='center' valign='top'><b>Current Order</b></td>
<td width='30%' align='center' valign='top'><b>Section Name</b></td>
<td width='50%' align='center' valign='top'><b>Desired Order</b></td></tr>
<tr><td width='20%' align='center' valign='top'><b>&nbsp;</b></td>
<td width='30%' align='center' valign='top'><b>&nbsp;</b></td><td width='50%' align='center' valign='top'><b>&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;</b></td></tr>
<tr><td width='20%' align='center' valign='top'>1</td>
<td width='30%' align='center' valign='top'>sec1</td>
<td width='50%' align='center' valign='top'>
<input type='radio' value='1' name='R1' ID='Radio1'>
<input type='radio' value='2' name='R1' ID='Radio1'>
<input type='radio' value='3' name='R1' ID='Radio1'>
</td></tr>
<tr><td width='20%' align='center' valign='top'>2</td>
<td width='30%' align='center' valign='top'>sec 2</td>
<td width='50%' align='center' valign='top'>
<input type='radio' value='1' name='R2' ID='Radio2'>
<input type='radio' value='2' name='R2' ID='Radio2'>
<input type='radio' value='3' name='R2' ID='Radio2'>
</td></tr>
<tr><td width='20%' align='center' valign='top'>3</td>
<td width='30%' align='center' valign='top'>sec 3</td>
<td width='50%' align='center' valign='top'>
<input type='radio' value='1' name='R3' ID='Radio3'>
<input type='radio' value='2' name='R3' ID='Radio3'>
<input type='radio' value='3' name='R3' ID='Radio3'>
</td></tr>
<tr><td width='20%'></td><td width='30%'></td><td width='50%' align='center' valign='top'><br><br><input type='submit' value='Update Section Order' name='Save'></td></tr></table></Form>

I have some validation code to make sure that atleast one radio button is checked in each radio group.

I need to validate that only one radio button is checked in each radio group having the same order( or value). (i.e., if Radio group R1 is checked and has a value of 2, then R2 and R3 should not have any radio button checked with value =2. Please remember that the set of Radio buttons is dynamic but will always have the same number of rows and columns.

Any help will be greatly appreciated.
Thank you.
PKS.
 
call a function using onClick on the last set of radio buttons and then check the other values using a getElementByID and then display appropriate message if need be
 
Could I have some sample Code please? I am just getting started with javascript.

Thank you.
PKS.
 
I can manage to include the onClick with the radio buttons.
I need some sample code for the validation using the getElementByID.

Thank you.
PKS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top