Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.4 kB
11
Indexable
Never
function validateForm() {
  var form = document.getElementById('myForm');
  var requiredFields = form.querySelectorAll('[required]');
  var firstInvalidField = null;

  requiredFields.forEach(function(field) {
    if (!field.value.trim() && !firstInvalidField) {
      firstInvalidField = field;
    }
  });

  if (firstInvalidField) {
    firstInvalidField.scrollIntoView({ behavior: 'smooth', block: 'center' });
    firstInvalidField.focus();
  } else {
    checkPhoneNumber();
  }
}

function checkPhoneNumber() {
  var phoneInput = document.getElementById('phone').value;
  var confirmPopup = document.getElementById('confirmPopup');
  var confirmPhone = document.getElementById('confirmPhone');

  confirmPhone.textContent = phoneInput;

  confirmPopup.classList.remove('hidden');
  document.body.style.overflow = 'hidden'; // Impedisce lo scrolling della pagina
}

function editPhoneNumber() {
  var confirmPopup = document.getElementById('confirmPopup');
  confirmPopup.classList.add('hidden');

  var phoneInput = document.getElementById('phone');
  phoneInput.scrollIntoView({ behavior: 'smooth', block: 'center' });
  phoneInput.focus();
  document.body.style.overflow = 'auto'; // Permette lo scrolling della pagina
}

function submitForm() {
  var form = document.getElementById('myForm');
  document.body.style.overflow = 'auto'; // Permette lo scrolling della pagina
  form.submit();
}
Leave a Comment