Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: RE: Radio Button Validation


Message #1 by "Jon Beer" <bringmebeer@y...> on Wed, 19 Feb 2003 04:58:42
The example below is missing a closing parentheses for the if condition, 
it should read...

if(!(document.forms[0].btnRadio[0].checked || 
document.forms[0].btnRadio[1].checked)) 
        {
 	alert("Please click a radio button!");
        }

> You have to check the "checked" property of each radio button 
individually
> 
> e.g.
> 
> if(!(document.forms[0].btnRadio[0].checked ||
> document.forms[0].btnRadio[1].checked){
> 	alert("Please click a radio button!");
> }
> 
> -----Original Message-----
> From: Nathan Nelson [mailto:nmnelson@k...]
> Sent: 18 June 2001 21:40
> To: javascript
> Subject: [javascript] Radio Button Validation
> 
> 
> How would I test to see if a user has selected a radio button so I can 
make
> it required that the user either chooses "YES" or "NO" using Javascript?
> 
> Thank you in advance
> 
> Nathan Nelson
> 

  Return to Index