Forum Replies Created

Viewing 1 replies (of 1 total)
  • 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();
    	}	
    });
Viewing 1 replies (of 1 total)