Heading

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

document.addEventListener('DOMContentLoaded', function() { function initCheckVATNumber() { document.getElementById('vat-number-checker-submit').addEventListener('click', function(event) { event.preventDefault(); checkVATNumber(); }); document.getElementById('vat-number-checker-another-valid').addEventListener('click', function() { document.getElementById('vat-number-checker-form').classList.remove('hidden'); document.getElementById('vat-number-checker-valid').classList.add('hidden'); }); document.getElementById('vat-number-checker-another-invalid').addEventListener('click', function() { document.getElementById('vat-number-checker-form').classList.remove('hidden'); document.getElementById('vat-number-checker-invalid').classList.add('hidden'); }); } function checkVATNumber() { var vatNumber = document.querySelector('input[name="vat-number"]').value.trim(); if (!vatNumber) return; const soapRequest = ` ${vatNumber.slice(0, 2)} ${vatNumber.slice(2)} `; fetch('http://ec.europa.eu/taxation_customs/vies/services/checkVatService', { method: 'POST', headers: { 'Content-Type': 'text/xml', 'SOAPAction': 'urn:ec.europa.eu:taxud:vies:services:checkVat/checkVat' }, body: soapRequest }) .then(response => response.text()) .then(responseText => { var parser = new DOMParser(); var xmlDoc = parser.parseFromString(responseText, "text/xml"); var valid = xmlDoc.getElementsByTagName("valid")[0].textContent === "true"; var name = xmlDoc.getElementsByTagName("name")[0].textContent; var address = xmlDoc.getElementsByTagName("address")[0].textContent; var requestDate = xmlDoc.getElementsByTagName("requestDate")[0].textContent; document.querySelector('input[name="vat-number"]').value = ''; document.getElementById('vat-number-checker-form').classList.add('hidden'); if (valid) { document.getElementById('vat-number-checker-valid').classList.remove('hidden'); document.getElementById('c-result-vat-number').textContent = vatNumber; document.getElementById('c-result-name').textContent = name; document.getElementById('c-result-address').textContent = address; document.getElementById('c-result-verification-date').textContent = requestDate; } else { document.getElementById('vat-number-checker-invalid').classList.remove('hidden'); document.getElementById('c-result-vat-number-invalid').textContent = vatNumber; document.getElementById('c-result-verification-date-invalid').textContent = requestDate; } }) .catch(error => { console.error('Error:', error); }); } initCheckVATNumber(); }); .c-spacer { height: 60px; } .c-status img { width: 50px; } .c-table-row { display: flex; text-align: left; } .c-table-column { flex: 1; } .c-table-column:last-child { font-weight: bold; } .c-invisible { opacity: 0; user-select: none; } .c-status img { margin-top: 0!important; margin-bottom: 0!important; }