<script>
    function validateAndSubmit() {
        const form = document.getElementById('form-user');
        const requiredFields = form.querySelectorAll('[required]');
        let allFieldsFilled = true;

        requiredFields.forEach(field => {
            if (!field.value.trim()) {
                allFieldsFilled = false;
                field.style.borderColor = 'red';
            } else {
                field.style.borderColor = '';
            }
        });

        if (allFieldsFilled) {
            form.submit();
        }
    }
</script>