Custom Validations
-
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)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Validations’ is closed to new replies.