• Resolved kimphuongtu135

    (@kimphuongtu135)


    Hello,

    I am trying to implement validation for the password field. For example, maximum of 10 letters, containing capital letters and special characters. Is that anyway I can do it?
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Sandip Pokhrel

    (@sandippokharel)

    Hi @kimphuongtu135

    Thanks for writing in,

    For limit the character, please add the following code in functions.php of you theme file.

    add_action( 'user_registration_validate_user_pass', 'ur_validate_user_pass_field', 10, 4 );
    function ur_validate_user_pass_field( $single_form_field, $data, $filter_hook, $form_id ) {
    	$field_label = isset( $data->label ) ? $data->label : '';
    	$password       = isset( $data->value ) ? $data->value : '';
    	if ( 10 < strlen( $password ) ) {
    		add_filter(
    		$filter_hook,
    		function ( $msg ) use ( $field_label ) {
    		return __( $field_label . ' cannot exceed 10 characters.', 'user-registration' );
    		}
    		);
    	}
    }

    Also, you can use ‘Enable Strong Password’ feature in the Form Setting to ask users to enter strong passwords.

    Regards!
    WPEverest Support Team.

    Plugin Support Sandip Pokhrel

    (@sandippokharel)

    Hi @kimphuongtu135,

    Since you haven’t written us back for few days/weeks, you are going to mark this ticket as resolved.
    Please let us know if you have any questions.

    Regards!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Validation for password’ is closed to new replies.