Radio Button Validation
Hello Friends pls help me if u can..I have jus started studying PHP..Ihave a doubt in radio button validation.
My doubt is that :I have to validate radioo buttons in two questions...my program is dealing with holiday registration...i am able to check the radiobuttons in first qn..how can i check the radio buttons in second qn also..pls help me with the code..the code i used for checking first set of radiobuttons is as follows...
if(!document.form1.RadioGroup1[0].checked && !document.form1.RadioGroup1[1].checked && !document.form1.RadioGroup1[2].checked && !document.form1.RadioGroup1[3].checked)
{
alert("Please select place");
return false;
}
return true;
Status:
Open Mar 13, 2008 - 03:52 AM
JavaScript, Web Design
3answers
Answers
Mar 17, 2008 - 10:21 AM
Ardra,
You've answered your own question - you check the second group the same way you checked the first group.
Using JavaScript (as you did in your example), you simply need to look at the "RadioGroup" associated with the second question.
If "RadioGroup1" is the name of the radio buttons for your first question, "RadioGroup2" could be the name of the radio buttons for your second question making your code look like the following:
(For question #1)
if(!document.form1.RadioGroup1[0].checked && !document.form1.RadioGroup1[1].checked && !document.form1.RadioGroup1[2].checked && !document.form1.RadioGroup1[3].checked)
{
alert("Please select an answer for question 1");
return false;
}
return true;
(For question #2)
if(!document.form1.RadioGroup2[0].checked && !document.form1.RadioGroup2[1].checked && !document.form1.RadioGroup2[2].checked && !document.form1.RadioGroup2[3].checked)
{
alert("Please select an answer for question 2");
return false;
}
return true;
Good luck in the PHP world...if you have any more questions, please feel free to post them!
Take care,
Ric
Mar 23, 2008 - 01:27 AM
Thank you Ric...
Mar 04, 2009 - 06:06 AM
The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.
The Quomon Team
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment