Create your account to find your trusted support / Créer votre compte gratuitement

Mrs.
Mr.

Desire to have a child
Undergoing fertility treatment
Pregnant
Postpartum
Parent



const situation = document.getElementById('current_situation');
const childrenInput = document.getElementById('children_birth_years');
const childrenLabel = document.getElementById('children_birth_label');

function toggleChildrenRequirement() {
if (situation.value === 'parent') {
childrenInput.required = true;
childrenLabel.innerHTML = "Year(s) of Birth of Children *";
childrenLabel.style.display = 'block';
childrenInput.style.display = 'block';
} else {
childrenInput.required = false;
childrenLabel.innerHTML = "Year(s) of Birth of Children";
childrenLabel.style.display = 'none';
childrenInput.style.display = 'none';
}
}

situation.addEventListener('change', toggleChildrenRequirement);
toggleChildrenRequirement();

const form = document.getElementById('parent-registration-form');
form.addEventListener('submit', function (e) {
e.preventDefault();
const data = new FormData(form);
data.append('action', 'parent_register_ajax'); // AJAX action

fetch('https://dev.mamavillage.fr/wp-admin/admin-ajax.php', {
method: 'POST',
body: data
})
.then(res => res.json())
.then(res => {
const resultDiv = document.getElementById('parent-registration-result');
if (res.success) {
resultDiv.innerHTML = '

' + res.data + '

';
form.reset();
toggleChildrenRequirement();
jQuery('.pop-up-contain').show();
setTimeout(()=>{
window.location.href = '/login/';
},3000)

} else {
resultDiv.innerHTML = '

' + res.data + '

';
}
})
.catch(err => console.error(err));
});