getQuery=(name)=>{
    return document.querySelectorAll(name);
}
getId=(idName)=>{
    return document.getElementById(idName);
}
let requiredFeild = getQuery(".required");
let requiredInput = getQuery("input");
let validateButton = getId("ValidationButton");
let pendingAmount = getId("pendingAmount");
feildValidate=()=>{
    let validateFunction=true;
requiredFeild.forEach((data)=>{
    if(data.value==""){
        data.classList.remove("required");
        data.classList.add("requiredvalue");
        validateFunction=false;
        console.log(data);
    }
    else{
        data.classList.remove("requiredvalue");
        data.classList.add("required");
    }
});
console.log(validateFunction);
return validateFunction;
}
requiredInput.forEach((data)=>{
    data.addEventListener("focus",function(){
        data.classList.remove("requiredvalue");
        data.classList.add("required");
    })
    data.addEventListener("keyup",function(){
        data.classList.remove("requiredvalue");
        data.classList.add("required");
    })
    data.addEventListener("change",function(){
        data.classList.remove("requiredvalue");
        data.classList.add("required");
    })
});
validateButton.addEventListener("click",function(){
    if(!feildValidate())
    {
        return;
    }
    console.log("yes");
    getId("submitButton").click();
});
amountValidation=()=>{
    let validation = false; 
    let totalAmt = Number(cashPay.value)+Number(bankPay.value);
 if(Number(totalAmt)>Number(pendingAmount.value)){
getId("alertPending").click();
validation=true;
}
console.log(validation);
return validation;
}
cashPay.addEventListener("keyup",function(){
       if(!amountValidation()){return;} 
       cashPay.value="";
});
bankPay.addEventListener("keyup",function(){
    if(!amountValidation()){return}; 
    bankPay.value="";
});