getQuery=(name)=>{
    return document.querySelectorAll(name);
}
getId=(idName)=>{
    return document.getElementById(idName);
}
let vehicleNo=getId("vehicleNo");
let loadType = getId("loadType");
let reloadPage =document.querySelectorAll(".reloadPage");
let requiredFeild = getQuery(".required");
let requiredInput = getQuery("input");
let validateButton = getId("validationButton");
let vehicleInside = getQuery(".vehicleallcomp");
console.log(requiredFeild);
loadType.addEventListener("change",function(e){
    let load = e.target.value;
    console.log(load);
    getId("limitValue").value=0;
    $("#customerAdd").val(null).trigger("change");
    (load == "Load")?getId("limitName").innerHTML="Advance:":getId("limitName").innerHTML="Credit-Limit:";
    });
    blockDateValidation=(data)=>{
    //let originalDate = getId("dateTkt").value;
    let originalDate = new Date();
    let originalDayDate = originalDate.getDate();
    let originalMonth=("0" + (originalDate.getMonth() + 1)).slice(-2);
    let originalYear = originalDate.getFullYear();
    let currentDate = originalYear+'-'+originalMonth+'-'+originalDayDate;
    console.log(originalYear+'-'+originalMonth+'-'+originalDayDate);
    if(loadType.value=="Empty")
            {
                if(data!='-'){
            if(data <= currentDate)
            {
                console.log(data);
                console.log(currentDate);
                console.log("blocked");
                getId("blockButton").click();
                
            }
        }
        }
    }
    limitValidation=(data)=>{
        let limit = getId("limitValue").value;
        let limitValue = getId("advanceLimitValue").value;
        console.log(limitValue);
     if(Number(data)>limit){
         if (loadType.value=="Empty")
          {
           
            getId("creditButton").click();
         }
         if(loadType.value=="Load")
             {
                 if(limitValue != 0)
                 {
              getId("alertAdvance").click();
            }
            }
                   
     }
    }
feildValidate=()=>{
    let validateFunction=true;
requiredFeild.forEach((data)=>{
    if(data.value==""||data.innerHtml==""){
        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;
}
validateButton.addEventListener("click",function(){
    if(!feildValidate())
    {
        return;
    }
    console.log("yes");
    getId("submitButton").click();
});
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");
    })
});
$(document).ready(function(){
$("#vehicleNo").on("change",function(){
 let vehicle = $(this).val();
 $(".vehicleallcomp").each(function(){
let vehicleInside = $(this).val();
if(vehicle == vehicleInside)
{
  
    $("#vehicleInsideAlert").click();
    $("#vehicleNo").val(null).trigger("change");
}
 });
});
});