• Resolved brookepalmer97

    (@brookepalmer97)


    Hi,

    I’m working on a mandatory login page where I need to have a birthdate entered. Right now, it seems you have to scroll back from month to month to get to the date. Although after taking a second look, I see that you can change the year by highlighting the year at the top and scrolling down on the years. I’m not sure how intuitive that would be for most people, and I’m trying to eliminate any deterrents to people signing up for my site.

    This site is intended only for those who are 18 and up. Is there an easier way for people to enter their birthdate? Maybe have a dropdown selector for the month, another for the date, and a final one for the year? For now, as a workaround, I’ve put an input field there, but I do prefer the actual date field.

    Also, I’m running into another issue with the built-in date field. I need to have the date validated. I entered a date where the person would have been under 18, and it still allowed me to create an account. Can date validation be done?

    Thanks!

    All the best,
    Brooke

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hello Brooke,

    Currently, we don’t have the feature like drop down selector for the month, another for the date, and a final one for the year. Also, we don’t also have a minimum date feature. We will surely look into this in future updates.

    If you have a input text to enter the age directly and having difficulty for validation. Please add this code to your child theme’s functions.php.

    add_action( 'user_registration_validate_text','ur_validate_text_field',10,4 );
    function ur_validate_text_field( $single_form_field, $data, $filter_hook, $form_id ) {
    	$field_label = isset( $data->label ) ? $data->label : '';
    	$value = isset( $data->value ) ? absint( $data->value ) : '';
    
    	if( 18 >= $value ) {
    	    add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
    	        return __( $field_label . ' should be greater than 18..', 'user-registration' );
    	   });
    	}
    }

    Also, note that this validation will apply for all extra input field added.

    [ Signature deleted ]

    • This reply was modified 6 years, 3 months ago by Jan Dembowski.
Viewing 1 replies (of 1 total)
  • The topic ‘Date Selector’ is closed to new replies.