Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 27th, 2007, 05:09 AM
Registered User
Join Date: Nov 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

  #2 (permalink)  
Old April 11th, 2007, 11:51 AM
Authorized User
Join Date: Jan 2007
Location: , , USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jonsey Send a message via Yahoo to jonsey

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;
  #3 (permalink)  
Old April 11th, 2007, 06:58 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
validation in radio buttons MunishBhatia ASP.NET 2.0 Professional 5 December 11th, 2007 11:15 AM
radio button anwarraja Javascript 3 September 18th, 2007 08:18 PM
Validation Radio Buttons jonsey Classic ASP Professional 1 June 6th, 2007 11:48 PM
Button acts depending on radio button values janise Access 4 March 10th, 2004 12:53 AM

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