<table>
<tr>
<th>Nombre</th>
<td><input type="text" name="nombre"/></td>
</tr>
<tr>
<th>Apellido</th>
<td><input type="text" name="apellido"/></td>
</tr>
<tr>
<th>Cedula</th>
<td><input type="text" name="cedula"/></td>
</tr>
<tr>
<th>Sexo</th>
<td><input type="text" name="sexo"/></td>
</tr>
</table>
<button type="submit" onclick ="guardarDatos();">Guardar</button>
I have the code that is supposed to work like this:
var DATOS = [];
function guardarDatos(){
inps= document.getElementsByTagName('input');
for(k in inps){
if(inps[k].value==''){
alert("Debe Completar "+inps[k].id);
return false;
}
}
}
But it does not do anything.