![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
05/11/2010, 13:45
|
![Avatar de blonder413](http://static.forosdelweb.com/customavatars/avatar371224_1.gif) | | | Fecha de Ingreso: octubre-2010
Mensajes: 58
Antigüedad: 14 años, 4 meses Puntos: 0 | |
Respuesta: validar un array vacío function Valida ()
{
if (IsChk('miCheckbox'))
{
//ok, hay al menos 1 elemento checkeado envía el form!
return true;
} else {
//ni siquiera uno chequeado no envía el form
alert ('Chequeame un elemento!');
return false;
}
}
function IsChk(chkName)
{
var found = false;
var chk = document.getElementsByName(chkName+'[]');
for (var i=0 ; i < chk.length ; i++)
{
found = chk[i].checked ? true : found;
}
return found;
} |