• Resolved isaiassilva1

    (@isaiassilva1)


    How to add custons validations

    example: this email are exists

    i’ve create a function check if email exists, but i need add custom validation “this email are exists”

    check atual function

    PHP

    // Query
    $sql = "SELECT FIELDS,STATUS FROM wp_evf_entries WHERE STATUS = 'publish' ";
    $result = $conn->query($sql);
    
    // request _POST
    $email = '';
    $email = $_POST['email'];
    
    if ($result->num_rows > 0) {
    	// output data of each row
    	while ($row = $result->fetch_assoc()) {
    		
    		// create array only email field
    		$varAux = explode(',', $row['FIELDS'], -1);
    		$varAux2 = explode('"', $varAux[6], -1);
    
    		// verify exist email
    		if($email == $varAux2[3]){
    			echo true;
    			return false;
    		}else{
    			echo false;
    		}
    	}
    }

    JQUERY

    <script>
    		jQuery(document).ready(function($) {
    			$("#evf-250-field_email").keyup(function() {
    				email = jQuery("#evf-250-field_email").val();
    				$.ajax({
    					type      : 'post', 
    					url       : 'validate_form.php', 
    					data      :  {email:email}, 
    					dataType  : 'html', 
    					success: function(result){
    						 if(result){
    							 jQuery("#evf-250-field_email").after("<label class='evf-error'>Este email já consta no banco de dados, verifique sua caixa de entrada e spam</label>");
                        jQuery(".evf-submit").prop('disabled', true);
    						 }
    						else{
    							jQuery("#evf-250-field_email").nextAll().remove();
                        jQuery(".evf-submit").prop("disabled", false);
    						}
    					}
    
    				}); 
    			});
    		});
    	</script>
Viewing 1 replies (of 1 total)
  • Saroj Shah

    (@wpeverestsupportrep)

    Hi there,

    Sorry for the late response. This issue requires proper testing for which, I request you to contact our developer team. You can contact them here: https://wpeverest.com/contact/ so that they will try to replicate the issue on your site and provide you the fix ASAP.

    Regards!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Validations’ is closed to new replies.