Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from mhazgui/val.php
Created November 15, 2024 14:56
Show Gist options
  • Save dexit/31ea0499fd0bcd0cef7939616e57aa71 to your computer and use it in GitHub Desktop.
Save dexit/31ea0499fd0bcd0cef7939616e57aa71 to your computer and use it in GitHub Desktop.
Elementor form validation
// Validate password form
add_action('elementor_pro/forms/validation', function ( $record, $ajax_handler ) {
//make sure its our form
$form_name = $record->get_form_settings( 'form_name' );
// Replace MY_FORM_NAME with the name you gave your form
if ( 'Sign-up' !== $form_name ) {
return;
}
$first_password_field = $record->get_field( [
'id' => 'password',
] );
$second_password_field = $record->get_field( [
'id' => 'confirmation_password',
] );
if ( $first_password_field['value'] !== $second_password_field['value'] ) {
$ajax_handler->add_error( $second_password_field['id'],'Confirmation Password must match the Password field' );
}
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment