Hi all,

I am new to this forum, but have many questions regarding javascript.

In this case, I have a form which contains two radio button groups: (yes/no

The idea is that the user is forced to select for each group one option, yes or no, and if they choose yes they have to fill in some text boxes.

I also have a general form validation, validation from Dreamweaver.

Everything is working ok, all validations are ok, except when the user does leaves the form blank and chooses NO in both radio groups. In this case, the validations stop working and the form is submitted with all fields blank.

This is my code for the validations. Thanks in advance for any help.


PHP Code:
<script type="text/javascript">
<!--
function 
validate(nForm){

        var 
firstQ nForm['firstSet'];
        var 
secondQ nForm['secondSet'];
        if (!
firstQ[0].checked && !firstQ[1].checked)
            {
             
alert('Por favor, indicanos si estas trabajando en la industria');
//             return false;
            
}
        if (!
secondQ[0].checked && !secondQ[1].checked)
            {
             
alert('Por favor, indicanos si estas estudiando cine');
             return 
false;
            }
        if (
firstQ[0].checked)
            {
             if (
nForm['Area'].value == "")
                {
                 
alert('Por favor, indicanos cual es tu area de trabajo');
//                 return false;
                
}
            }
//        else    {
//             document.getElementById('firstNew1').disabled = true;
//             document.getElementById('firstNew2').disabled = true;
//            }
        
if (secondQ[0].checked)
        {
             if (
nForm['Escuela'].value == "" || nForm['especialidad'].value == "")
                {
                 
alert('Por favor, indicanos cual es tu especialidad y en que escuela estas estudiando');
                 return 
false;
                }
            }
//        else     {
//             document.getElementById('secondNew1').disabled = true;
//             document.getElementById('secondNew2').disabled = true;
//            }

        
return true
    }
        

function 
MM_findObj(nd) { //v4.01
  
var p,i,x;  if(!dd=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    
d=parent.frames[n.substring(p+1)].documentn=n.substring(0,p);}
  if(!(
x=d[n])&&d.allx=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(
i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!
&& d.getElementByIdx=d.getElementById(n); return x;
}

function 
MM_validateForm() { //v4.0
  
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (
i=0i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (
val) { nm=val.name; if ((val=val.value)!="") {
      if (
test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (
p<|| p==(val.length-1)) errors+='- '+nm+' debe ser una direccion de e-mail valida.\n';
      } else if (
test!='R') { num parseFloat(val);
        if (
isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (
test.indexOf('inRange') != -1) { p=test.indexOf(':');
          
min=test.substring(8,p); max=test.substring(p+1);
          if (
num<min || max<numerrors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (
test.charAt(0) == 'R'errors += '- '+nm+' es obligatorio.\n'; }
  } if (
errorsalert('Ocurrieron los siguientes errores:\n'+errors);
  
document.MM_returnValue = (errors == '');
}
//-->
</script> 
and this is the onsubmit property of the form

PHP Code:
<form action="carga_con_control.asp" method="post" name="form1" onsubmit="MM_validateForm('Nombre','','R','Apellido','','R','email','','RisEmail');return validate(this);return document.MM_returnValue"