I have a dynamic input that I draw with
for (var j = 0; j < valorCantidad; j++) {
contador = contador + 1;
jQuery('#tblTabla1 tr:last').after('<tr>' +
'<td align="center" class="valorId">' + contador + '</td>' +
'<td align="center" class="valorInt">' + valorInterno + '</td>' +
'<td align="center" class="valorFa">' + valorFa + '</td>' +
'<td align="center" class="valorArt">' + valorAr + '</td>' +
'<td align="center">'+
'<input type="text" id="numeroSerie-' + contador + '" name="Serie" placeholder="Ingrese número de serie" class="form-control" onblur="validacionSeries(numeroSerie-' + contador + ');" />'+
'<div id="divError-' + contador + '"></div>'+
'</td>'+
'</tr>');
and this is my function
<script>
function validacionSeries(txt) {
alert("ok"+txt);
var m = document.getElementById(valorTxt).value;
alert(m);
var expreg = new RegExp("^[0-9]{15,19}$");
if (expreg.test(m)) {
alert("ok");
} else {
alert("no");
};
};
</script>
As you can see, I add a JS onblur="validacionSeries(numeroSerie-' + contador + ');"
method to the textbox, but it sends me a message of numeroSerie
that is not defined, I do not understand why, if I remove the variable that passed as a parameter the function is executed well (only that I put in the function without parameter a alert
).