• Resolved itsmir

    (@itsmir)


    Hello,

    I have a form with a dropdown list of names/email addresses.

    I would like to validate/set a rule for the email field to not be allowed to be populated with any email from the dropdown list.

    Can you hep with this??

    Thanks in advance

    Miriam

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @itsmir

    I hope you are doing well today.

    I pinged our Forminator & SLS Team to review your query to see what will be possible in this matter. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Thread Starter itsmir

    (@itsmir)

    Hiya, client has changed requirements & we no longer need this so I’ve marked it resolved. Thanks for your time.

    Hi @itsmir

    Just as a refer for you and future queries this is the code which you can use as a mu-plugin

    add_filter( 'forminator_custom_form_submit_errors', 'wpmudev_limit_email_submission', 9999, 3 );
    function wpmudev_limit_email_submission( $submit_errors, $form_id, $field_data_array ) {
    	if ( $form_id != 6 ) { //Please change the form ID
    		return $submit_errors;
    	}
    
    	$submitted_data = wp_list_pluck( $field_data_array, 'value', 'name' );
    
        if ( ! empty( $submitted_data['select-1'] ) && ! empty( $submitted_data['email-1'] ) ) {
            if ( $submitted_data['select-1'] == $submitted_data['email-1'] ) {
                $submit_errors[]['email-1'] = __( 'E-Mail Not Allowed.', 'forminator' );
            }
        }
    
    	return $submit_errors;
    }

    This snippet should help. 6 should be changed to your form ID and select-1email-1 should be changed to your select field and email field’s ID.

    A guide to implement below code as a mu-plugin on your site https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Kind Regards,
    Kris

    Thread Starter itsmir

    (@itsmir)

    Brilliant- thank you. I’ll add it to my snippet bank 🙂

    And in the likelihood my client changes their minds again it’ll be in hand.

    • This reply was modified 3 years, 1 month ago by itsmir.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Valdiate Email address’ is closed to new replies.