I have a code piece that generates id dynamically as checc1, checc2 etc for each dynamically created textboxes respectively. How can I get these values to the variable boxc one by one?
function GetDynamicTextBox(value) {
var nextRowID = 0;
var id = ++nextRowID;
return value+' : '+'<input class="dynfield" name = "'+value+'" id="checc' + id + '" type="text" value = "" />' + '<input type="hidden" name="fieldnames[]" value="'+value+'"/>' + '<br>' + '<br>'
}
This is my code right now and it is wrong. This is the code in which I need the values of checc for performing validation to those dynamically created text boxes. Should I use a loop?
function boxCheck() {
var boxc = $('#checc').val();
if (boxc.length == 0) {
$('#p9').text("* Cannot be blank *");
$("#checc").parents(".chenn").addClass("error");
return false;
} else {
$("#checc").parents(".chenn").removeClass("error");
return true;
}
}
var id = 1; var boxc = $('#checc' + id).val();?