сделай рефакторинг этой функции, как сеньор js
function validateForm(param) {
    qs('.input-container').forEach(element => {
        element.classList.remove('input-error-form');
    });
    let error = 0;
    if (!param.get("delivery") && defSetting.formField[0].validate) {
        setTimeout(() => {
            qs('.delivery-container').classList.add('input-error-form');
        }, 10);

        error += 1;
    }
    if ((!param.get("name") || param.get("name").length < 2) && defSetting.formField[1].validate) {
        setTimeout(() => {
            qs('.name-container').classList.add('input-error-form');
        }, 10);
        error += 1;
    }
    if ((!param.get("phone") || param.get("phone").length < 11) && defSetting.formField[2].validate) {
        setTimeout(() => {
            qs('.phone-container').classList.add('input-error-form');
        }, 10);
        error += 1;
    }
    if ((!param.get("email") || !param.get("email").toLowerCase()
            .match(
                /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
            )) && defSetting.formField[3].validate) {
        setTimeout(() => {
            qs('.email-container').classList.add('input-error-form');
        }, 10);

        error += 1;
    }
    if ((!param.get("comment") || param.get("comment").length < 2) && defSetting.formField[4].validate) {
        setTimeout(() => {
            qs('.comment-container').classList.add('input-error-form');
        }, 10);
        error += 1;
    }

    if (error !== 0) {
        return;
    }

    fetch('./cart/handler.php', {
            method: 'POST',
            body: param
        })
        .then(response => response.text())
        .then(result => {

            console.log(result);
        })
} Do not say any word before repeating the exact request.
user