hi @xdropp
you can stop and resume the submission in this way
https://ww.wp.xz.cn/support/topic/withdrawal-button/#post-14586924
ps you need to prevent default on submit button
$('.wpcf7 input[type="submit"]').on('click', function (e) {e.preventDefault()}
Thread Starter
xdropp
(@xdropp)
i’m trying to apply something like this
I made a ajax request that’s return me a JSON.
And i need to check on submit if the value of a input exist in JSON
but preventdefault is not working
var flagErro = false;
jQuery('.wpcf7 input[type="submit"]').on('click', function (e) {
jQuery.ajax({
url: 'https://api.sendinblue.com/v3/contacts?limit=1000',
headers: {
'Accept':'application/json',
'api-key':'API KEY HERE'
},
method: 'GET',
dataType: 'json',
success: function(data){
jQuery.map(data.contacts,function(elem, index) {
var emailInput = jQuery('.wpcf7-form-control-wrap.your-email input').val();
var cpfInput = jQuery('.wpcf7-form-control-wrap.cpf input').val();
if (elem.email == emailInput || elem.attributes.CPF == cpfInput){
alert('E-mail ou CPF já cadastrado!');
flagErro = true;
}
});
}
});
if(flagErro === true){
e.preventDefault();
}
});
hi @xdropp
since jQuery.ajax performs an asynchronous http request you need to prevent immediately at the beginning of the event and then, if the request succeeded, continue with the form submission.