Ver Mensaje Individual
  #225 (permalink)  
Antiguo 04/08/2005, 12:21
Avatar de Saruman
Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 20 años, 11 meses
Puntos: 5
227. Validar que el usuario seleccione al menos un CheckBox

P: ¿Cómo puedo validar que el usuario seleccione al menos un checkbox?
R: Utilizando esta función:

Código PHP:
<script language="javascript">
function 
validar_checkbox() { 
var 
total f.opciones.length;
var 
selected false;
 
if (
total != null) {
for (
i=0i<totali++) {
    if (
f.opciones[i].checked == true) {
     
selected true;
     break;
    }
}
} else {
if (
f.opciones.checked == true) {
    
selected true;
}
}
 
if (
selected == false) {
alert("Debe seleccionar al menos una opción.");
return 
false
}
}
</script> 
también puedes ver: http://www.forosdelweb.com/showpost....9&postcount=22

Enjoy!
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.

Última edición por KarlanKas; 06/09/2005 a las 01:49