This is a custom code placeholder.
Switch to Preview or publish the page
to see how your code works.
Double-click to edit
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@300;400;500;600&display=swap" rel="stylesheet">
<style>
.phone-group {
display: flex;
align-items: center;
}
.phone-group select, .phone-group input[type="number"] {
flex: 1;
margin-right: 10px;
}
body {
font-family: 'Raleway', sans-serif;
background-color: #f9f4f0;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 50px auto;
padding: 30px;
border-radius: 20px;
background-color: #fff6f2;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
padding-left: 10px;
font-size: 1.2em;
font-weight: 600;
}
.input-field, .input-select {
width: 100%;
padding: 12px;
margin: 10px 0;
border-radius: 5px;
box-sizing: border-box;
border: 1px solid #ddd;
}
.input-checkbox {
transform: scale(1.5);
margin-right: 10px;
margin-top: 10px;
}
.error-message {
color: red;
display: none;
}
button {
padding: 12px 20px;
border-radius: 5px;
border: none;
font-weight: 600;
cursor: pointer;
font-size: 1.1em;
}
button[type="submit"], .btn-next {
background-color: #f95c5b;
color: white;
}
.btn-prev {
background-color: #f0f0f0;
color: black;
}
/* Aumenta la dimensione della checkbox per mobile */
@media only screen and (max-width: 600px) {
input[type="checkbox"] {
transform: scale(2.0);
}
}
.checkbox-group {
display: flex;
align-items: start; /* Allinea in alto rispetto al testo dell'etichetta */
margin-top: 10px;
}
.checkbox-group input[type="checkbox"] {
margin: 0 10px 0 0;
}
.checkbox-group label {
font-size: 0.8em;
flex: 1; /* Permette all'etichetta di prendere tutto lo spazio rimanente */
}
</style>
</head>
<body style="font-family: 'Raleway', sans-serif; background-color: #f9f4f0;">
<div class="container">
<form id="formData" action="https://hook.eu1.make.com/ayju8h2dfd06slt1jmhtgqfmnfoirlsb" method="post">
<!-- Step 1 -->
<div id="step1" style="display:block;">
<label for="name" style="font-size: 1.2em; font-weight: 600;">Nome:</label>
<input type="text" id="name" name="name" required class="input-field">
<p id="nameError" class="error-message">Il campo Nome è obbligatorio.</p>
<label for="surname" style="font-size: 1.2em; font-weight: 600;">Cognome:</label>
<input type="text" id="surname" name="surname" required class="input-field">
<p id="surnameError" class="error-message">Il campo Cognome è obbligatorio.</p>
<label for="email" style="font-size: 1.2em; font-weight: 600;">Email:</label>
<input type="email" id="email" name="email" required s class="input-field">
<p id="emailError" class="error-message">Inserisci un indirizzo email valido.</p>
<button type="button" onclick="nextStep()" style="display: block; margin: 20px 0; padding: 12px 20px; border-radius: 5px; background-color: #f95c5b; border: none; color: white; font-weight: 600; cursor: pointer; font-size: 1.1em;">Avanti</button>
</div>
<!-- Step 2 -->
<div id="step2" style="display:none;">
<label for="birthdate" style="font-size: 1.2em; font-weight: 600;">Data di nascita del tuo bebè o data presunta del parto:</label>
<input type="date" id="birthdate" name="birthdate" required class="input-field">
<label for="whatsappPrefix" style="font-size: 1.2em; font-weight: 600;">Numero WhatsApp (facoltativo):</label>
<div class="phone-group">
<select id="whatsappPrefix" name="whatsappPrefix" class="input-field">
<option value="+39">+39 (Italia)</option>
<!-- Puoi aggiungere altre opzioni per altri paesi dell'UE qui -->
<option value="+33">+33 (Francia)</option>
<option value="+34">+34 (Spagna)</option>
<!-- ... -->
</select>
<input type="number" id="whatsappNumber" name="whatsappNumber" class="input-field">
</div>
<p id="whatsappError" style="color:red; display:none;">Inserisci un numero WhatsApp valido.</p>
<br>
<div class="checkbox-group">
<input type="checkbox" id="privacy1" name="privacy1" required>
<label for="privacy1">Confermo di aver letto l'informativa sulla privacy e acconsento al trattamento dei miei dati per la ricezione della miniguida. I dati non saranno ceduti a terzi. *</label>
</div>
<div class="checkbox-group">
<input type="checkbox" id="privacy2" name="privacy2">
<label for="privacy2">Confermo di aver letto l'informativa sulla privacy e acconsento al trattamento dei miei dati per la ricezione della miniguida. I dati non saranno ceduti a terzi.</label>
</div>
<button type="button" onclick="previousStep()" style="display: inline-block; margin: 10px 5px; padding: 8px 15px; border-radius: 5px; background-color: #f0f0f0; border: none; color: black; cursor: pointer; font-weight: 500; font-size: 1.1em;">Indietro</button>
<button type="submit" style="display: inline-block; margin: 10px 5px; padding: 12px 20px; border-radius: 5px; background-color: #f95c5b; border: none; color: white; font-weight: 600; cursor: pointer; font-size: 1.1em;">SCARICA LA MINIGUIDA</button>
</div>
</form>
</div>
<script>
function validateStep1() {
let valid = true;
// Check if name is filled
if(!document.getElementById('name').value.trim()) {
document.getElementById('nameError').style.display = "block";
valid = false;
} else {
document.getElementById('nameError').style.display = "none";
}
// Check if surname is filled
if(!document.getElementById('surname').value.trim()) {
document.getElementById('surnameError').style.display = "block";
valid = false;
} else {
document.getElementById('surnameError').style.display = "none";
}
// Check if email is valid
let email = document.getElementById('email').value;
let emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if(!emailRegex.test(email)) {
document.getElementById('emailError').style.display = "block";
valid = false;
} else {
document.getElementById('emailError').style.display = "none";
}
return valid;
}
function validateStep2() {
let valid = true;
let whatsappNumber = document.getElementById('whatsappNumber').value.trim();
// La regex controlla che il numero sia composto da 8-10 cifre
let whatsappRegex = /^\d{8,10}$/;
// Controllo del numero WhatsApp
if(whatsappNumber && !whatsappRegex.test(whatsappNumber)) {
document.getElementById('whatsappError').style.display = "block";
valid = false;
} else {
document.getElementById('whatsappError').style.display = "none";
}
return valid;
}
function nextStep() {
if(validateStep1()) {
document.getElementById('step1').style.display = 'none';
document.getElementById('step2').style.display = 'block';
}
}
function previousStep() {
document.getElementById('step2').style.display = 'none';
document.getElementById('step1').style.display = 'block';
}
document.getElementById('formData').addEventListener('submit', function(event) {
event.preventDefault();
if (!validateStep2()) {
alert("Si prega di compilare il modulo correttamente prima di inviarlo.");
return;
}
// Combina prefisso e numero di telefono
let whatsappPrefix = document.getElementById('whatsappPrefix').value;
let whatsappNumber = document.getElementById('whatsappNumber').value.trim();
let fullWhatsappNumber = whatsappPrefix + whatsappNumber;
// Aggiungi il numero completo al formData prima di inviare
let formData = new FormData(document.getElementById('formData'));
formData.append('fullWhatsappNumber', fullWhatsappNumber);
// Send the custom event to Facebook Pixel
fbq('trackCustom', 'DWNLD lead magnet'); // <-- Add this line here
// Fetch API to send data
fetch('https://hook.eu1.make.com/ayju8h2dfd06slt1jmhtgqfmnfoirlsb', {
method: 'POST',
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
window.location.href = 'https://nuvitababy.com/pages/mini-guida-gravidanza-in-arrivo';
})
.catch(error => {
console.error('Error:', error);
alert("C'è stato un errore nell'invio del modulo. Riprova più tardi.");
});
// Send a message to the parent page
window.parent.postMessage('formSubmitted', '*');
});
</script>
</body>
</html>