Good, I have put a small questionnaire and in the end I have a checkbox to accept the subject of privacy policies. But I can not check whether they have selected it or not.
I would like an alert to come out when it has NOT been selected
$(document).ready(function() {
var estructuraMail = /^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;
$('#Btn-Contacto-Enviar').click(function() {
var nombre = $('#Nombre').val();
var apellidos = $('#Apellidos').val();
var mail = $('#Mail').val();
var telefono = $('#Telefono').val();
var comentario = $('#Comentario').val();
var checkLOPD = $("#Checkbox-lopd:checked");
if (nombre == "") {
alert("El campo nombre es obligatorio");
} else {
if (apellidos == "") {
alert("El campo apellidos es obligatorio");
} else {
if (mail == "") {
alert("El campo e-Mail es obligatorio");
} else {
if (!estructuraMail.test(mail)) {
alert("El correo electrónico no es válido");
} else {
if (telefono == "") {
alert("El campo teléfono es obligatorio");
} else {
if (isNaN(telefono)) {
alert("El numero de teléfono ha de ser numérico");
} else {
if (comentario == "") {
alert("¡Cuéntame algo!");
} else {
if( $('#Checkbox-lopd').is(':checked') ) {
alert('Seleccionado');
}
}
}
}
}
}
}
}
});
});
Greetings!