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 9110089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:11:36+00:00 2026-06-17T03:11:36+00:00

I am using the bootstrap-datepicker in my site. The datepicker will be used to

  • 0

I am using the bootstrap-datepicker in my site. The datepicker will be used to define search filters. I need the initial value of the datepicker input element to be empty, so it will not introduce the date filter for the search results. When the user clicks on the text input linked to Datepicker, the Datepicker popup box should select the first day of next month.

Problem: If I were to set an initial date (as shown below), the text input will be populated with today’s date which is not what I want. However if i do not set the initial date, the datepicker will show 1970s. What should I do?

Similar to: The demo for jQueryUI Datepicker

JS Code

var now = new Date();
var nextMonth = new Date();
nextMonth.setDate(1);
nextMonth.setMonth(now.getMonth() + 1);
var prettyDate =  nextMonth.getMonth() + '/' + nextMonth.getDate() + '/' + nextMonth.getFullYear();
$('#listing_filter_available').val(prettyDate);
$('#listing_filter_available').datepicker();

HTML Code

<input type="text" id="listing_filter_available" class="input-small" placeholder="Date Available" />

Failed Attempt

Datepicker does not popup on clicking the text input el

$(function() {

    var now = new Date();
    var nextMonth = new Date();
    nextMonth.setDate(1);
    nextMonth.setMonth(now.getMonth() + 1);
    var prettyDate =  nextMonth.getMonth() + '/' + nextMonth.getDate() + '/' + nextMonth.getFullYear();
    $('#listing_filter_available').val('');  // clear the date filter
    $('#listing_filter_available').click( function() {
        $('#listing_filter_available').val(prettyDate);
        $('#listing_filter_available').datepicker();
    });

});
  • 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-06-17T03:11:37+00:00Added an answer on June 17, 2026 at 3:11 am

    I just encountered a very similar use case. With a couple of tweaks to bootstrap-datepicker.js, I believe I’ve got it working.

    You’ll need to edit the script in two places.

    For the date field, I’m checking to see if the date (this.date) is set to the Unix start date (.e.g blank date). If so, exit and leave the field blank.

    (line: 95 – approx)

        setValue: function () {
            // EDIT - Don't setValue if date = unix date start
            if (DPGlobal.formatDate(this.date, this.format) == DPGlobal.formatDate(new Date(1970, 1, 1, 0, 0, 0), this.format)) return false;
            // END EDIT
    

    For the drop down calendar, I’m also checking to see if the date (this.date) is set to the Unix start date. If so, set the date to today. I’m doing this so that when a user clicks on the date field, it displays the current month as opposed to Feb 1970.

    (line: 144 – approx)

    fill: function () {

          //  EDIT - Set date in fill to today if date is "blank" (eg Unix start date)
                var d = ((DPGlobal.formatDate(this.date, this.format) == DPGlobal.formatDate(new Date(1970, 1, 1, 0, 0, 0), this.format))) ? new Date() : new Date(this.viewDate),
          //  original code
                //    var d = new Date(this.viewDate),
          //  END EDIT 
    

    I believe that’s all you need to do. I’ve just implemented this in my solution, so if anybody finds any issues or has any better suggestions, I’d love to hear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using bootstrap-datepicker and get a value of 1339698600000 for the selected date
I am using bootstrap-datepicker.js and it is working fine. <div class=well> <div id=dp5 class=input-append
Using Bootstrap, I cannot figure out what I need to center MiDs element so
I'm using the bootstrap datepicker plugin and I need to overload the headTemplate object
I am using bootstrap on my site and am having issues with the navbar
Using Bootstrap, appending more than one button to a .form-search rounds the right corners
In my current project I am using the Bootstrap datepicker to allow users to
I am using the yii booster bootstrap, but datepicker is not working. I also
I'm using Bootstrap v2.1.1, and I can't insert two datepicker objects on the same
I using bootstrap carousel on my site. The problem in that the plugin shows

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.