ou aspas no valor
var telInternacional = 1;
var funcaoMaiorIdade = 0;
function validaTelefone() {
if (funcaoMaiorIdade === '1') {
var maiorIdade = document.querySelector('#maior_idade');
var checkboxContainer = document.querySelector('.checkbox-modern');
checkboxContainer.classList.remove('erro');
if (!maiorIdade.checked) {
alert('Você precisa confirmar que é maior de 18 anos para continuar.');
checkboxContainer.classList.add('erro');
return false;
}
}
var telefone = document.getElementById('telefone').value
var telefone_confirm = document.getElementById('telefone_confirm').value
if (telefone != telefone_confirm) {
alert('Telefone não confere!');
return false;
}
}
function loginCliente() {
var formData = new FormData(document.getElementById('form'))
var telefone = formData.get('phone');
if (telefone.length < 14 && telInternacional == 0) return;
$.ajax({
url: "https://sistemarifa.com.br/login-cliente",
type: 'POST',
dataType: 'json',
data: {
telefone: telefone,
loginCPF: loginCPF
},
success: function(response) {
if (response.GTMEvent) {
sendGTMEvent(response.GTMEvent);
}
if (response.GA4Event) {
sendGA4Event(response.GA4Event)
}
if (response.cliente) {
window.location.href = 'https://sistemarifa.com.br/minhas-compras'
} else {
document.getElementById('page-content').innerHTML = response.html
if (loginCPF) {
document.getElementById('telefone').focus()
} else {
document.getElementById('telefone_confirm').focus()
}
applyMasks();
}
},
error: function(error) {
alert('Erro interno!')
}
})
}
$(function(e) {
var button = document.getElementById('button');
// Enable/Disable Button
document.getElementById('phone').addEventListener('input', function(el) {
if (telInternacional == 1) {
button.disabled = false;
return
}
if (el.target.value.length < 14) {
button.disabled = true;
} else {
button.disabled = false;
}
});
// Form prevent default
document.getElementById('form').addEventListener('submit', function(el) {
el.preventDefault();
loginCliente();
});
})