p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   asp radio button array validation (http://p2p.wrox.com/showthread.php?t=55891)

steve1234 March 27th, 2007 05:09 AM

asp radio button array validation

I want to validate a form which has approx 36 fields in which I accpt the reponses from radio button (yes/NO/NA). I need to know the Javascript which would validate all the 36 field radio buttons in an array and return the pointer where the radio button was left and not selected.
<td width="68" align="center"><input type="radio" value="1" name="OP_1" onClick=0></td>
        <td width="68" align="center"><input type="radio" value="2" name="OP_1" onClick=0></td>
        <td width="69" align="center"><input type="radio" value="0" name="OP_1" onClick=0></td>
        <td type "hidden" width="5" align="center">
<td width="68" align="center"><input type="radio" value="1" name="OP_2"></td>
        <td width="68" align="center"><input type="radio" value="2" name="OP_2"></td>
        <td width="69" align="center"><input type="radio" value="0" name="OP_2"></td>
<td width="68" align="center"><input type="radio" value="1" name="OP_3"></td>
        <td width="68" align="center"><input type="radio" value="2" name="OP_3"></td>
        <td width="69" align="center"><input type="radio" value="0" name="OP_3"></td>

The above examples state 3 fields, there are 33 more like this.
Please help

jonsey April 11th, 2007 11:51 AM

here is a JavaScript that would look for all the radio button and see what there status is if emptyl/unchecked it would simply say please check all radio buttons.

Code in JavaScript

for (i=0, n=theForm.radios.length; i<n; i++) {
if (theForm.radios[i].checked) {
     var checkvalue = theForm.radios[i].value;
why += checkRadio(checkvalue);

function checkRadio(checkvalue) {
var error = "";
if (!(checkvalue)) {
     error = "Please check a radio button.\n";
return error;

mat41 April 11th, 2007 06:58 PM


My 2cents worth - Most people look at radio button and assume limited selections should be made. IMO checkboxes should be used if you would like many selections. Am I a bit old school, or is this still the case?

Wind is your friend

All times are GMT -4. The time now is 07:52 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.