This is my coding for dynamic field validation. if i use this function i got 'TypeError: document.getElementById(...) is null' this kind of error.
function sr_answer_val(){
var cnt=parseInt(document.getElementById("add_field_cnt").value);
var submitAllow=true;
for(var i=1;i<cnt;i++){
if(document.getElementById("cust_field_"+i).value ==''){
alert('Answer Should be Mandatory');
submitAllow=false;
return false;
}
}
}