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

  • Home
  • SEARCH
  • 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 3308954
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:34:58+00:00 2026-05-17T21:34:58+00:00

I have a Datepicker using jqueryui DatePicker. The behavior requirement is: A User can

  • 0

I have a Datepicker using jqueryui DatePicker.

The behavior requirement is:

  • A User can store a Birthdate for a friend. The User should be able to store a year if known, or select “N/A”.

  • If “N/A” is selected, Store the year 1900 in the database and only display the day and month in an input field to the User.

  • The dropdown should start at 1950 but show the past 100 years from current date (<– this would be icing on the cake, otherwise start at current year and if necessary go back to 1900)

Here’s what I got so far, but it’s kludgey…and that’s an understatement. And for some reason, if the user selects a date, but doesn’t alter the year dropdown, then the current year is stored, rather than 1900.

(it’s in the context of a json call). Surely there’s a better way.

var birthday_options = {changeMonth: true, changeYear: true, yearRange: '1900:2010',
        onClose: function(dateText, inst) {
        contact.field_updater('birthday').call(this);
        $('input.mng-birthday').val(function(i, val) {
                       return val.replace('/1900', '');
                    });
        },
        beforeShow: function (input) {
                      setTimeout(function () {
                        $('select.ui-datepicker-year option:first').text('N/A');                                                                 
                      }, 1);
                    }},

.find('.mng-birthday').val(data.birthday || 'Unknown')
  .datepicker(birthday_options)
.end(); 
  • 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-17T21:34:58+00:00Added an answer on May 17, 2026 at 9:34 pm

    Click here to see a demo.

    When you find yourself out of scope, the jQuery UI source is easy to modify. You just need to change the function definition for _generateMonthYearHeader:

    // StackOverflow question: Add option for N/A
    html += '<option value="1900">N/A</option>';
    

    And make this change to _selectDay to ommit the year when N/A is selected.

    // StackOverflow question: format the date
    if (inst.currentYear == 1900)
        this._selectDate(id, (inst.currentMonth + 1) + "/" + inst.currentDay);
    else
        this._selectDate(id, this._formatDate(inst, inst.currentDay,
                         inst.currentMonth, inst.currentYear));
    

    In the script panel you have the core UI script, the modified datpicker script, and the setup:

    $(document).ready(function() {
        var year = new Date().getFullYear();
    
        $(".mng-birthday").datepicker({
            changeYear: true,
            // The year range is from the current year to 100 years before
            yearRange: (year - 100) + ":" + year,
            // The default date is january 1st fifty years before the current year
            defaultDate: "01/01/1900"
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the jQuery datepicker from jqueryui.com and I have a problem changing the
I have a datepicker control setup using the JQuery UI, I am also using
I am currently using jquery ui datepicker for forms that have date inputs. The
I have a jQuery datepicker that I want to restrict non work days -
I've have finally got the datepicker to work on my MVC demo site. One
I have a rather frustrating problem where the maximum number of available DatePicker's on
What's the object type returned by Datepicker? Supposing I have the following: $(#txtbox).datepicker({ onClose:
Have just started using Google Chrome , and noticed in parts of our site,
I'm using the jQuery datepicker to select dates. It works fine, except there is
I am trying to implement the Jquery datepicker using a google hosted theme. But

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.