How can I remove specific date range from dropdown date field?

I created a new registration form using WP FORMS. Need to remove the date range from 2017 to 2000 from the form field "My Birthday" on this page -

  • Huberson

    Hey Meg,
    Try adding this JS snippet to your custom JavaScript:

    var all_years = document.getElementById('wpforms-field_6-year');
    function markDateRange(years) {
    	for (var i = 1; i < years.length; i++) {
    		if(years[i].value > 1999) {
    			years[i].className = 'remove-year';
    var years2remove = document.getElementsByClassName('remove-year');
    while (years2remove[0]) {

    You can use "Add Custom JS" option of Simple Custom CSS & JS plugin to do that.

    If that doesn't take care of it let us know and we will check that.


  • Huberson

    Hi there,
    Strange, it works fine when I test it. Try clearing or resting any caching, this might be causing the issue. You can also test the below scripts. Both do the same thing so you might want to try them individually.


    	var all_years = $('#wpforms-field_6-year').children();
    	all_years.each( function (index) {
    		if( !isNaN( $(this).val() ) && $(this).val() > 1999 ) {
    	var removed_years = $('.remove-year').remove();


    var all_years = jQuery('#wpforms-field_6-year').children();
    all_years.each( function (index) {
    	if( !isNaN( jQuery(this).val() ) && jQuery(this).val() > 1999 ) {

    If that doesn't work, you could try adding any of the scripts in a javascript file and add it under your theme js folder. You'll then include the script by adding this snippet in functions.php file locate inside the active theme directory:
    wp_enqueue_script( 'script', get_template_directory_uri() . '/js/yourscript.js', array ( 'jquery' ), 1.1, true);

    Feel free to ask additional information if needed.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.