I'm using the jquery validation plugin. My goal is to check whether a user is present in the database before sending the form. If present then I ask it to connect by displaying a modal connection
function checkemail() {
jQuery.noConflict();
$("#frompopupcontactpublic").validate({
rules: {
email: {
required: true,
email: true,
remote: "/?controller=pjAdminUsers&action=pjActionCheckEmail"
}
}
});
}
function opencnx() {
$("#cnxfrom").modal('show');
}
$(document).on('click', '#idbtn', function () {
jQuery.noConflict();
$.ajax({
type : "POST",
cache : false,
url : "/send_contact.php",
data : $(this).serializeArray(),
beforeSend: function () {
if(!checkemail()) {
//opencnx();
alert('here');
return false;
} else {
alert('or here');
}
},
success: function(msg){
if(msg=='send')
{
$(".reponsecontenu").html(msg);
$(".reponse").modal('show');
}
},
error: function () {
alert("failure");
$("#result").html('There is error while submit');
}
});
return false;
});
Do you know why the validation () starts before beforeSend ?