
<script>
    document.addEventListener('DOMContentLoaded', function() {
        const checkbox = document.getElementById('checkbox');
        const customcategorybox = document.getElementById('customcategorybox');
        const selectcategory = document.getElementById('category_id');

        if (checkbox && customcategorybox && selectcategory) {
            checkbox.addEventListener('change', function() {
                if (this.checked) {
                    customcategorybox.style.display = 'block';
                    selectcategory.style.display = 'none';
                    selectcategory.value = '';
                } else {
                    customcategorybox.style.display = 'none';
                    selectcategory.style.display = 'block';
                }
            });
        }
    });

    document.addEventListener('DOMContentLoaded', function () {
    const input = document.getElementById('number');
    const mask = '+7 (___) ___-__-__';

    function numbermask(event) {
        let i = 0;
        let val = input.value.replace(/\D/g, '');

        input.value = mask.replace(/./g, function(char) {
            if (/[_\d]/.test(char) && i < val.length) {
                return val.charAt(i++);
            } else if (i >= val.length) {
                return '';
            } else {
                return char;
            }
        });
    }
    if(input){
        input.addEventListener('input', numbermask, false);
    }
    
});



</script>