Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3852556
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:20:07+00:00 2026-05-19T17:20:07+00:00

I developed one web page that contains DOB field. So i developed 3 dropdowns

  • 0

I developed one web page that contains DOB field. So i developed 3 dropdowns DdlYear, DdlMonth, DdlDay. Now i want code snippet that 3 dropdowns are changing dynamically in javascript.when the user selects a leap year then feb month contains 29 days and number of days should be shown according to the month.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:20:08+00:00Added an answer on May 19, 2026 at 5:20 pm

    I think the following code snippet may solves your problem.

    $(document).ready(function () {

        $("#DpdwnMonth").change(function () {
    
            if ($("#DpdwnYear").val() !== "0" && ($("#DpdwnYear").val()) % 4 === 0 && $("#DpdwnMonth").val() === "2") {
                if ($('#DpdwnDay :last').val() === "31") {
                    $("option[value='30']").remove();
                    $("option[value='31']").remove();
                }
                else if ($('#DpdwnDay :last').val() === "28") {
                    var myOptions = { 29: '29' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
    
                    });
                }
                else if ($('#DpdwnDay :last').val() === "30") {
                    $("option[value='30']").remove();
                 }
            }
    
            else if ($("#DpdwnMonth").val() === "4" || $("#DpdwnMonth").val() === "6" || $("#DpdwnMonth").val() === "9" || $("#DpdwnMonth").val() === "11") {
                if ($('#DpdwnDay :last').val() === "31") {
                    $("option[value='31']").remove();
    
                }
                else if ($('#DpdwnDay :last').val() === "29") {
                    var myOptions = { 30: '30' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
    
                    });
                }
                else {
                    var myOptions = { 29: '29', 30: '30' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
    
                    });
                }
            }
            else if ($("#DpdwnMonth").val() === "2") {
                $("option[value='29']").remove();
                $("option[value='30']").remove();
                $("option[value='31']").remove();
    
            }
            else {
                if ($('#DpdwnDay :last').val() === "28") {
                    var myOptions = { 29: '29', 30: '30', 31: '31' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
                    });
    
                }
                else if ($('#DpdwnDay :last').val() === "29") {
                    var myOptions = { 30: '30', 31: '31' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
                    });
    
                }
                else if ($('#DpdwnDay :last').val() === "30") {
                    var myOptions = { 31: '31' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
                    });
    
                }
    
            }
    
        });
    
        $("#DpdwnYear").change(function () {
    
            if ($("#DpdwnYear").val() !== "0" && ($("#DpdwnYear").val()) % 4 === 0 && $("#DpdwnMonth").val() === "2") {
                if ($('#DpdwnDay :last').val() === "31") {
                    $("option[value='30']").remove();
                    $("option[value='31']").remove();
                }
                else if ($('#DpdwnDay :last').val() === "28") {
                    var myOptions = { 29: '29' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
    
                    });
                }
                else if ($('#DpdwnDay :last').val() === "30") {
                    $("option[value='30']").remove();
                }
            }
    
            else if ($("#DpdwnMonth").val() === "4" || $("#DpdwnMonth").val() === "6" || $("#DpdwnMonth").val() === "9" || $("#DpdwnMonth").val() === "11") {
                if ($('#DpdwnDay :last').val() === "31") {
                    $("option[value='31']").remove();
    
                }
                else if ($('#DpdwnDay :last').val() === "29") {
                    var myOptions = { 30: '30' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
    
                    });
                }
                else {
                    var myOptions = { 29: '29', 30: '30' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
    
                    });
                }
            }
            else if ($("#DpdwnMonth").val() === "2") {
                $("option[value='29']").remove();
                $("option[value='30']").remove();
                $("option[value='31']").remove();
    
            }
            else {
                if ($('#DpdwnDay :last').val() === "28") {
                    var myOptions = { 29: '29', 30: '30', 31: '31' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
                    });
    
                }
                else if ($('#DpdwnDay :last').val() === "29") {
                    var myOptions = { 30: '30', 31: '31' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
                    });
    
                }
                else if ($('#DpdwnDay :last').val() === "30") {
                    var myOptions = { 31: '31' };
                    $.each(myOptions, function (val, text) {
                        $('#DpdwnDay').append($('<option></option>').val(val).html(text));
                    });
    
                }
    
            }
    
        });
    
        $("#DpdwnDay").change(function () {
            if ($("#DpdwnYear").val() === "0" && $("#DpdwnDay").val() !== "0") {
                $("#DpdwnDay").val("0");
                alert("Select first year");
                return false;
            }
    
            if ($("#DpdwnMonth").val() === "0" && $("#DpdwnDay").val() !== "0") {
                $("#DpdwnDay").val("0");
                alert("Select first month");
                return false;
    
            }
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop a php web page that contains two dropdownlists (select tags) as one
I have a web project that I developed where one of the main functions
I developed one database related application for iPhone device(SQlite database). Now i want to
I'm debugging someone else's code for a web page that is made with ASP.NET
I developed one simple android application targeting the Mobiles with android 2.0 OS.I want
I have a webapp development problem that I've developed one solution for, but am
I have developed a web application (ASP.NET Web Forms). One of my customer has
I just did an audit of one of my web application page (built using
In my .NET web applications I usually have a Scripts folder that contains all
I developed a web-based training matrix that shows the training record for each employee

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.