Here's how to use Elementor Forms to allow only business email addresses to be entered in the Email Field. Here's how to do it. You simply have to follow the simple steps below!

Your website should have the following configurations in order for it to function properly:

The code for forms API

Elementor Pro is an extension of Elementor that adds new features to the core of the application. As part of the Forms API, you have the ability to filter and validate content, implement webhooks, execute custom code and accomplish a lot more.

Form Field Validation Action


It is a POST request which has the form action in it after the forms module has been loaded. Then you can therefore validate the different fields individually.

This hook's name, $field_type, is made up of the field type in the dynamic portion of the hook's name.

fieldArrayThe submitted field.
recordForm_RecordThe record was submitted.
ajax_handlerAjax_HandlerThe Ajax Handler component.
// Validate the email fields for valid domains
add_action( 'elementor_pro/forms/validation/email', function( $field, $record, $ajax_handler ) {
// Please include the email domains you would like to block in this list
$invalidDomains = ["@gmail.","@yahoo.","@hotmail.","@live.","@aol.","@outlook."];
	// email validation
	foreach($invalidDomains as $domain){
		if(strpos($field['value'], $domain) !== false){
    	$ajax_handler->add_error( $field['id'], "Must be Business email." ); 
}, 10, 3 );

Would you like to 
receive more WordPress 

You can tell us anything you want and we'll make it happen. Whatever it takes, whatever it seems like it will be.
Social Media
Copyright © 2022. All rights reserved.
Privacy Policy | Terms & Condition