Email Validation using JQuery or PHP! (Elementor on Wordpress) #15359
YASK95
announced in
Developers Community
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
Im looking to validate business emails by filtering common email ids such as @yahoo.com @gmail.com etc.. Im looking to do this with JS as shown in the image.
Been breaking my head over this for over 2 months because there are no plugins that support this functionality(tried dynamicoo, contact 7 etc)
I have tried with contact 7, but it still doesnt filter outlook and yahoo. Here is the code i have used inside Contact7:
function blocked_email_domain($email) {
$blocked = array("@gmail.com", "@hotmail.com", "@yahoo.com", "@yahoo.in","@msn.com", "@live.com", "@outlook.com", "@microsoft.com", "@zoho.com", "@rediff.com");
$email = strstr($email, '@');
if(in_array($email, $blocked))
return false;
else
return true;
}
function custom_email_validation_filter($result, $tag) {
$type = $tag['type'];
$name = $tag['name'];
if($name == 'your-email') { // Only apply to fields with the form field name of "your-email"
$the_value = $_POST[$name];
if(!blocked_email_domain($the_value)){
$result['valid'] = false;
$result->invalidate( $tag, 'You need to provide an email address that isn't hosted by a free provider.
Please contact us directly if this isn't possible.');
};
};
return $result;
}
add_filter('wpcf7_validate_email','custom_email_validation_filter', 10, 2); // Email field
add_filter('wpcf7_validate_email*', 'custom_email_validation_filter', 10, 2); // Required Email field
Now as a last solution im trying to insert JQuery into elementor! Need help with a new code!
TIA
Beta Was this translation helpful? Give feedback.
All reactions