Ver Mensaje Individual
  #25 (permalink)  
Antiguo 02/12/2002, 09:27
Avatar de Mickel
Mickel
 
Fecha de Ingreso: mayo-2002
Ubicación: Lima, Peru
Mensajes: 4.619
Antigüedad: 21 años, 11 meses
Puntos: 7
25.- Validación de radio buttons

P: Como comprobar si todos los radios buttons de un formulario han sido respondidos

R:
Código PHP:
var el document.(tu formulario).elements;
for (var 
el.length ; ++i) {
    if (
el[i].type == "radio") {
        var 
radiogroup el[el[i].name];
        var 
itemchecked false;
        for (var 
radiogroup.length ; ++j) {
            if (
radiogroup[j].checked) {
            
itemchecked true;
            break;
            }
        }
        if (!
itemchecked) { 
            
i=0;
            break;
        }
    }
}
if (
i>0) {
    return 
true;
} else {
    
alert("No ha respondido todas las preguntas");
    return 
false;


Última edición por Kaopectate; 02/10/2003 a las 14:51