I already have the validator jquery with other rules of other static inputs, but I am adding some inputs through 'jquery' of the form:
var ReglasValoracion1a1000 = {
required: true,
digits: true,
range: [0, 1000],
normalizer: function (value) {
value = value.replace(" ", "");
return $.trim(value);
},
}
function ImprimirSoloInput(Sessiones)
{
var div = '';
var SessionNumero = 0;
for (var i = 0; i < Sessiones; i++) {
SessionNumero = i + 1;
div += '<div class="form-group" >' +
'<span class="col-md-3 control-label">' + TiempoEnMinutos + ' ' + SessionNumero +'</span>' +
'<div class="col-md-5">' +
'<input name="TiempoEnMinuto[]" class="form-control TiempoEnMin" id="TiempoEnMinuto' + SessionNumero + '">' +
'</div>' +
'</div>';
}
$('#sessiones').html(div);
AddRulesSessiones(Sessiones)
}
function AddRulesSessiones(Sessiones) {
var SessionNumero = 0;
//$("input[name=TiempoEnMinuto]").rules('add', ReglasValoracion1a1000);
//for (var i = 0; i < Sessiones; i++) {
// SessionNumero = i + 1;
// $("#TiempoEnMinuto" + SessionNumero).rules('add', ReglasValoracion1a1000);
//}
$('input.TiempoEnMin').each(function () {
console.log($(this));
$(this).rules("add",
{
required: true
});
});
}
I have tried with the commented lines and the each of the AddRulesSessiones function but, when I click on the submit form button, it validates only the first input that the PrintOnInput function adds.