JSFiddle - React, Tailwind, and code Playground
HTML
<div class="tiempote">
<p> <span class="titulo_te">{new}</span>
<span class="pop_te">{msj}.</span>
</p>
<form id="form1" name="form1" method="post" enctype="multipart/form-data">
<label>Fecha de la medición</label>
<input name="fec" type="text" id="fec" class="obligatorio" readonly="readonly" /> <span class="avisopop" id="obg_fec"></span>
<br />
<table border="1" cellpadding="0" cellspacing="0" id='tiempos_te'>
<tr>
<td title="Debe ser 8 dígitos numéricos máximo">
<p align="center">Nro. Factura</p>
</td>
<td title="Debe colocar el tiempo en formato MINSEC (el campo colocara automaticamente los ":")">
<p align="center">Montar té</p>
</td>
<td title="Debe colocar el tiempo en formato MINSEC (el campo colocara automaticamente los ":")">
<p align="center">Armado del vaso</p>
</td>
<td title="Debe colocar el tiempo en formato MINSEC (el campo colocara automaticamente los ":")">
<p align="center">Armado del té</p>
</td>
<td>
<p align="center">Tiempo total</p>
</td>
<td>
<p align="center">Turno</p>
</td>
</tr>
<tr>
<td>
<input name="fac1" type="text" id="fac1" onKeyPress="return acceptNum(event)" maxlength="10" class="obligatorio" />
</td>
<td>
<input type="text" name="tiempo11" id="tiempo11" class="obligatorio tiempo" maxlength="6" onKeyPress="return acceptNum(event)" />
</td>
<td>
<input type="text" name="tiempo12" id="tiempo12" class="obligatorio tiempo" maxlength="6"...
JavaScript
$.fn.sumValues = function () {
var sum = 0;
this.each(function () {
if ($(this).is(':input')) {
var val = $(this).val();
} else {
var val = $(this).text();
}
sum += parseFloat(('0' + val).replace(/[^0-9-\.]/g, ''), 10);
});
return sum;
};
function acceptNum(e) {
return e;
}
$(document).ready(function () {
var counter = 2;
$("#addButton").click(function () {
if (counter > 6) {
alert("Solo se permiten 6 Mediciones por dia");
return false;
}
$('#tiempos_te').append('<tr>' +
'<td><input name="fac' + counter + '" type="text" id="fac' + counter + '" onKeyPress="return acceptNum(event)" maxlength="10" class="obligatorio"/></td>' +
'<td> <input type="text" name="tiempo' + counter + '1" id="tiempo' + counter + '1" class="obligatorio tiempo" maxlength="6" onKeyPress="return acceptNum(event)" /></td>' +
'<td> <input type="text" name="tiempo' + counter + '2" id="tiempo' + counter + '2" class="obligatorio tiempo" maxlength="6" onKeyPress="return acceptNum(event)" /></td>' +
'<td> <input type="text" name="tiempo' + counter + '3" id="tiempo' + counter + '3" class="obligatorio tiempo" maxlength="6" onKeyPress="return acceptNum(event)" /></td>' +
'<td><input type="text" name="totalt' + counter + '" id="totalt' + counter + '" readonly="readonly" class="total_tiempo" /></td>' +
'<td><select name="turn' + counter + '" id="turn' + counter + '" class="obligatorio">' +
'<option value="2">Vespertino</option>' +
'<option value="3">Nocturno</option>' +
'</select></td>' +
'</tr>');
counter++;
});
/*var reg1 = /^(tiempo)(1)(1|2|3)$/;
var reg2 = /^(tiempo)(2)(1|2|3)$/;
var reg3 = /^(tiempo)(3)(1|2|3)$/;
$("input[name^='tiempo']").bind( "blur", function() {
//alert($(this).attr('name'))
if (...