Validate a form and make sure a user chosses a radio button if they've selected 'yes' to the previous question.

I've got a form on a page which is quite big. For speed's sake, I've used Yaromat's dreamweaver extension to validate the form - and it does a good job, however, I need to alert the user if choose 'yes' to one question but then don't select an answer to another question.

First Question:

"Are you currently using the software?"
Yes
 <input type="radio" name="q1software" value="Yes" >

No
<input type="radio" name="q1software" value="No" >

Second question:

"If so, what version?"

V9
<input type="radio" name="q1version" value="V9" >
V8

<input type="radio" name="q1version" value="V8" >

Other

<input type="radio" name="q1version" value="Other" >


If the user chooses 'Yes' in the first question, they need to then choose something from the next bit.

Any ideas?

Also, it needs to sit alongside the existing javascript entry, can I call two javascript functions from the same submit button?
andycalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

p_parthaCommented:
check this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script>
function partha()
{
firstval = checkControl("q1software")
if (firstval=="Yes")
{
secondval = checkControl("q1version")
if (secondval=="")
{
alert('you have to select second option')
return false
}
}
}
function checkControl(strFieldName){
    var objFormField = document.forms[0].elements[strFieldName]
    intControlLength = objFormField.length
    bolSelected = false;
    for (i=0;i<intControlLength;i++){
         if(objFormField[i].checked){
                   bolSelected = true;
                   break;
         }
    }    
     if (!bolSelected)
             return ""
         return objFormField[i].value
   
}





</script>
<title>Untitled</title>
</head>
<body >
<form>
"Are you currently using the software?"
Yes
<input type="radio" name="q1software" value="Yes" >


<input type="radio" name="q1software" value="No" >
"If so, what version?"

V9
<input type="radio" name="q1version" value="V9" >
V8

<input type="radio" name="q1version" value="V8" >

Other

<input type="radio" name="q1version" value="Other" >


<input type='button' onclick='partha()'>
</form>
</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andycalAuthor Commented:
Thankyou, thankyou, thanyou, sorted, customer happy!

Plus you made me laugh with the BoSelected var.
0
p_parthaCommented:
Thanks for the points, I had teh function for checkbox picked from this forum, i just changed it to ur need

Partha
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.