How to skip row without data and validate only row containing data
hi allwhat i want is i have one button addnewrow if i click on it it will add row one by one so some rows may contain data some may not so when i click on save button only the validation shoulb be done for rows containing data others should be skipped and data should be saved in db
this is my function so what to do give me some idea
function validateIncome(){
var flgSave = false;
var flgIsEdit = false;
var RowCnt=0;
var VaildRowCnt=0;
$("#incomeGridB >tbody >tr").each(function () {
var tr = $(this);
var displayMode = tr.find("td > label").css("display");
if (displayMode == 'inline-block' || displayMode == 'block') {
RowCnt ++;
flgIsEdit = true;
if(tr.find("#customer").val()=="Select"){
displayAlert("Please select the customer.");
return false;
}
if(tr.find("#plnContract").val()=="Select"){
displayAlert("Please select the contract status.");
return false;
}
if(tr.find("#plnContractNo").val().trim()==""){
displayAlert("Please enter the contract number.");
return false;
}
if(tr.find("#strtMnth").val()=="Select"){
displayAlert("Please select the start month.");
return;
}
if(tr.find("#endMnth").val()=="Select"){
displayAlert("Please select the end month.");
return false;
}
if(tr.find("#endMnth").prop('selectedIndex')<tr.find("#strtMnth").prop('selectedIndex')){
displayAlert("End month should be greater than start month.");
return false;
}
var flgMonthValPresent = false;
for(var i=1;i<=12;i++){
if(tr.find("#month"+i).val().trim()!=""){
flgMonthValPresent = true;
}
}
if(!flgMonthValPresent){
displayAlert("Please enter the amount for atleast one month.");
return false;
}
VaildRowCnt++;
}
});
if(RowCnt==VaildRowCnt){
flgSave = true;
}
if(toDelete.length>0 && flgIsEdit==false){
flgSave = true;
flgIsEdit = true;
}
if(!flgIsEdit){
displayAlert("There is no data entered/modified to save.");
flgSave = false;
}
return flgSave;
}