Hi all,
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.
How can I get the radio button validation working when there is only 1 radio
on the page ?
Many thanks, Blinky. 6 3123
Blinky wrote on 29 nov 2005 in comp.lang.javas cript: 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.
How can I get the radio button validation working when there is only 1 radio on the page ?
Radio buttons should according to specs always be in a group with one
selected. some browsers accept bad html programming with zero selected, but
unselecting by the user is never possible.
That is why having only one radio button in a form is senseless.
Use checkboxes for your purpose.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Thanks Evertjan,
I cannot use checkboxes as I cannot have more then one item selected. My
problem is when a search returns only 1 result. Even if this one result is
checked the validation code still does not validate it. What do you think I
can do instead ?
Cheers, Blinky.
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.242.. . Blinky wrote on 29 nov 2005 in comp.lang.javas cript: 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.
How can I get the radio button validation working when there is only 1 radio on the page ?
Radio buttons should according to specs always be in a group with one selected. some browsers accept bad html programming with zero selected, but unselecting by the user is never possible.
That is why having only one radio button in a form is senseless.
Use checkboxes for your purpose.
-- Evertjan. The Netherlands. (Replace all crosses with dots in my emailaddress)
Blinky wrote: I cannot use checkboxes as I cannot have more then one item selected. My problem is when a search returns only 1 result. Even if this one result is checked the validation code still does not validate it. What do you think I can do instead ?
If your search returns only 1 result, why not mark it as CHECKED by default?
Otherwise, validating radio buttons needs to be slightly different depending
on if it's a collection of objects or a single object. A general lib like http://www.JavascriptToolbox.com/validations/ will allow you to get input
values regardless of the number of inputs you have with the same name.
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
Blinky wrote: Thanks Evertjan,
I cannot use checkboxes as I cannot have more then one item selected. My problem is when a search returns only 1 result. Even if this one result is checked the validation code still does not validate it. What do you think I can do instead ?
Please don't top post. Reply below trimmed, quoted text.
A single radio button doesn't make sense. They should only be used if
there are two or more. Why not use a checkbox if there is only one
result and radios if 2 or more?
[...]
--
Rob
JRS: In article <il************ *****@news-server.bigpond. net.au>, dated
Tue, 29 Nov 2005 13:04:14 local, seen in news:comp.lang. javascript,
Blinky <xx***********@ 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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
"Dr John Stockton" <jr*@merlyn.dem on.co.uk> wrote in message
news:X1******** ******@merlyn.d emon.co.uk... JRS: In article <il************ *****@news-server.bigpond. net.au>, dated Tue, 29 Nov 2005 13:04:14 local, seen in news:comp.lang. javascript, Blinky <xx***********@ 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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources. <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Thanks everyone,
I have changed my code and validate server side now.
Cheers, Blinky This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sman |
last post by:
Hi, I recently read this article on About.com on how to create
required fields for a form:
http://javascript.about.com/library/scripts/blformvalidate.htm
Everything works great except that there are no instructions on how to
make checkboxes and radio buttons required. I've tried adding these to
my form, but I'm having no luck. Anyone know how to add radio buttons
and checkboxes using the existing code mentioned on the url?
Thank you!
|
by: sakms |
last post by:
I am attempting to validate radio buttons in Netscape with JavaScript.
Everything works excellent in Explorer, but refuses to work in Netscape
(all versions).
=========== JAVASCRIPT CODE ========================
function ValidateTest()
{
|
by: Claire Lescarret |
last post by:
Hello,
I have devoted my time to write valid html 4.01 strict, and CSS-1 and 2
*but* I also have to use third party's code for webcounter (StatCounter) and
Google's SiteSearch, which are preventing my pages from validating.
I woudn't like to take away those services, but I also would like to show my
valid pages... Any suggestions will be greatly appreciated!
Thanks in advance.
|
by: Leszek |
last post by:
Hi
I've got html form and i want to validate it using javascript
I have somerthing like this:
<p>
<b>Gender: <font color="red">*</font></b>
<input type="radio" value="Male" name="gender">Male
<input type="radio" value="Female" name="gender">Female
|
by: Advo |
last post by:
Hi there. Having a few issues and cannot see a way to actually do the
following.
ive duplicated a simple questionnaire as shown here:
http://www.hackeradio.com/questionnaire.html
meaning there are 8 questions, each with 8 possible answers.
Each row of the answers has its own name ie:
question12_answer1 - question12_answer8
| |
by: Suma |
last post by:
Hi,
i have a problem with the controls .i have to validate Form1 Radio
button option is checked or Not in the Form2. even after checking the
radio button also in FOrm2 it is always taking as "False" only.
please see the following code where i did wrong.
I ahve created A Visual C# .Net project. for that i ahve added Form2
now my project contains Form1 and Form2.
In Form1 i have placed Control "RadioButton1"
|
by: SONIQ |
last post by:
Using javascripts to validate this form.
Basic operation, when a user clicks the submit order button, the javascript code must validate everything entered by the user.
Please help finnish this form.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
|
by: forbes |
last post by:
Hi,
I have a form that contains multiple groups of checkboxes that act
like radio buttons (at the clients insistance).
There is one text field that is required and 28 checkbox groups.
Here an example of a checkbox group:
<td><input type="checkbox" name="trusted" value="1" id="ck_ttt1"
onclick="...
<td><input type="checkbox" name="trusted" value="2" id="ck_ttt2"
|
by: satyabhaskar |
last post by:
hi all,
In my web page i have created radio buttons dynamically on to the page .....following is my code
string Course, Semester, Section;
int rowsCount;
string con = ConfigurationManager.ConnectionStrings.ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
try
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |