Re: Validating radio
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Validating radio

From: Dr John Stockton <jrs@merlyn.demon.co.uk>
Date: Wed Nov 30 2005 - 17:03:13 CET

JRS: In article <ilYif.6647$ea6.4138@news-server.bigpond.net.au>, dated
Tue, 29 Nov 2005 13:04:14 local, seen in news:comp.lang.javascript,
Blinky <xxnospamxxweh@bigpond.net.au> posted :

>I have a dynamically generated page that can have 1 or more radio buttons. I
>am using javascript with onsubmit in the form statement to make sure a radio
>button is selected before allowing the page to be submitted. At the moment
>it only works when there is 2 or more radio buttons on the page.

So you need to change your validation code.

>How can I get the radio button validation working when there is only 1 radio
>on the page ?

With dynamic material, you may legitimately have only one line of the
button-deserving type. If you count them before you generate them, you
can omit the button if there's only one line.

Alternatively, you can have a permanent Button Zero, selected by
default, labelled "none of them"; and validate by checking that it is
cleared.

But your code is wrong.
 

-- 
 © John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v4.00   IE 4 ©
 <URL:http://www.jibbering.com/faq/>  JL/RC: FAQ of news:comp.lang.javascript 
 <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
 <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Received on Sat Dec 3 04:33:38 2005