• Resolved capichepdi

    (@capichepdi)


    Hi,

    I have created a form to assist with registration on my website. I found a code snippet from a previous support thread which will assist in getting the email confirmed.

    I want to know if there is a way for the validation to not be case sensitive.

    for example:

    email-1: info@xyz.com

    email-2: Info@xyz.com

    This throws an error that the email does not match.

    Thanks for assisting.

    Below is the code used.

    /*-----------------------------------------------------------------------------------*/
    
    /*  Forminator Email verification
    
    /*-----------------------------------------------------------------------------------*/
    
     add_filter( 'forminator_custom_form_submit_errors', 'check_form_data', 99, 3 );
    
    function check_form_data( $submit_errors, $form_id, $field_data_array ) {
    
    $email1 = $email2 = '';
    
    foreach( $field_data_array as $arr ) {
    
    if( $arr['name'] == 'email-1' ) $email1 = $arr['value'];
    
    if( $arr['name'] == 'email-2' ) $email2 = $arr['value'];
    
    if( '' != $email1 && '' != $email2 ) break;
    
    }
    
    if( $email1 != $email2 ) {
    
    $submit_errors[]['email-2'] = 'The email addresses must match!';
    
    }
    
    return $submit_errors;
    
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @capichepdi

    I hope you are doing well today.

    I pinged our SLS Team so that they can review you query. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Hi @capichepdi

    Here is the updated code which should help:

    add_filter( 'forminator_custom_form_submit_errors', 'check_form_data', 99, 3 );
    function check_form_data( $submit_errors, $form_id, $field_data_array ) {
    	$email1 = $email2 = '';
    	foreach( $field_data_array as $arr ) {
    		if( $arr['name'] == 'email-1' ) $email1 = $arr['value'];
    		if( $arr['name'] == 'email-2' ) $email2 = $arr['value'];
    		if( '' != $email1 && '' != $email2 ) break;
    	}
    
    	if( strtolower($email1) != strtolower($email2) ) {
    		$submit_errors[]['email-2'] = 'The email addresses must match!';
    	}
    
    	return $submit_errors;
    }

    Kind Regards,
    Kris

    Thread Starter capichepdi

    (@capichepdi)

    Many thanks.

    This worked perfectly. Thanks for the prompt response.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Confirm Email validation case Sensitive’ is closed to new replies.