Ver Mensaje Individual
Antiguo 04-ago-2005, 12:21   #225 (permalink)
Saruman
Saruman está en el buen camino
 
Avatar de Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panamá
Mensajes: 1.154
Enviar un mensaje por MSN a Saruman Enviar un mensaje por Yahoo  a Saruman
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: FAQs JavaScript

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-sep-2005 a las 01:49.
Saruman está desconectado   Responder Citando