* Validate phone format for israeli numbers.
 * Supports:
 * @param array        $field        Form field.
 * @param Form_Record  $record       An instance of the form record.
 * @param Ajax_Handler $ajax_handler An instance of the ajax handler.
function dorzki_validate_phone_elementor( $field, $record, $ajax_handler ) {

	if ( preg_match( '/^((0\d{1,2}\-\d{7})|(0\d{8,9}))$/', $field['value'] ) !== 1 ) {

		$ajax_handler->add_error( $field['id'], esc_html__( 'Phone number format is invalid, please enter the phone number without spaces and special chars.', 'dorzki' ) );



add_action( 'elementor_pro/forms/validation/tel', 'dorzki_validate_phone_elementor', 10, 3 );

How to use it?

Usually adding functionality to a WordPress site is by creating a plugin.
However you can simply copy the code and paste it in your child theme’s functions.php file at the end of the file, just before ?>.

For JavaScript code you will need to add them to your theme’s main JavaScript file.

Having issues with the code?

If the code doesn’t work or you get an error please let us know in the comments section.
We will do our best to fix it as-soon-as-possible and update the code on this page.


Leave a Reply