add_action( 'elementor_pro/forms/validation', function ( $record, $ajax_handler ) {
$form_name = $record->get_form_settings( 'form_name' );
// EMAIL
// Replace MY_FORM_NAME with the name you gave your form
if ( 'OrderForrm' !== $form_name ) {
return;
}
//Replace MY_FIELD_ID_1 to match the field's Advanced > Field ID
$first_email_field = $record->get_field( [
'id' => 'email'
] );
//Replace MY_FIELD_ID_2 to match the field's Advanced > Field ID
$second_email_field = $record->get_field( [
'id' => 'email_confirm'
] );
//Make sure your field ID's are set to match these in each field's Advanced > Field ID
if ( $first_email_field['email']['value'] !== $second_email_field['email_confirm']['value'] ) {
$ajax_handler->add_error( $second_email_field['email_confirm']['id'], 'Confirmation Email must match the Email field' );
}
//PHONE
//Replace MY_FIELD_ID_1 to match the field's Advanced > Field ID
$first_phone_field = $record->get_field( [
'id' => 'phone'
] );
//Replace MY_FIELD_ID_2 to match the field's Advanced > Field ID
$second_phone_field = $record->get_field( [
'id' => 'phone_confirm'
] );
//Make sure your field ID's are set to match these in each field's Advanced > Field ID
if ( $first_phone_field['phone']['value'] !== $second_phone_field['phone_confirm']['value'] ) {
$ajax_handler->add_error( $second_phone_field['phone_confirm']['id'], 'Confirmation Phone Number must match the Phone Number field' );
}
}, 10, 2 );