-
-
Save dexit/31ea0499fd0bcd0cef7939616e57aa71 to your computer and use it in GitHub Desktop.
Elementor form validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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