Pruebalo así, luego intenta descomentado
return o
//continue
Código HTML:
Ver original<script type="text/javascript"> function sumar(c) { //alert(c);
var campo = document.getElementById('form1');
var subtotal = 0;
if (!/^d*$/.test(c)) // <-- problema, busca solución
//return;
for (var i = 0; i < campo.length - 1; i++) {
if (!/^d+$/.test(campo[i].value)) // <-- problema, busca solución
// continue;
subtotal += parseFloat(campo[i].value);
}
document.form1.res.value = subtotal;
}
<form id="form1" name="form1" action="" method="post"> 1:
<input type="text" name="sum[]" value="0" onKeyUp="sumar(this.value);" /><br />2:
<input type="text" name="sum[]" value="0" onKeyUp="sumar(this.value);" /><br />3:
<input type="text" name="sum[]" value="0" onKeyUp="sumar(this.value);" /><br />4:
<input type="text" name="sum[]" value="0" onKeyUp="sumar(this.value);" /><br />5:
<input type="text" name="sum[]" value="0" onKeyUp="sumar(this.value);" /><br />6:
<input type="text" name="sum[]" value="1.1" onKeyUp="sumar(this.value);" /><br /> Resultado:
<input type="text" id="res" name="res" value="0" />