Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/03/2007, 09:29
Avatar de JavierB
JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 23 años
Puntos: 772
Re: validar 2 checkbox de un formulario

Hola seckron

Prueba este ejemplo:

Código PHP:
<html>
<
head>
<
script type="text/javascript">
function 
validar(frm) {
  
num=0;
  for(
i=0ele=frm.elements[i]; i++)
    if (
ele.type=='checkbox' && ele.checked)
      
num++
  if (
num<2) {
    
alert('Error');
    return 
false;
  }
}
</script>
</head>
<body>
<form onsubmit="return validar(this)">
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
<input type="submit" />
</form>
</body>
</html> 
Saludos,