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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:45:28+00:00 2026-05-28T02:45:28+00:00

I have two inputs, startdate and enddate , and I am using datepicker of

  • 0

I have two inputs, startdate and enddate, and I am using datepicker of jQuery UI.

I have two questions:

(1) How to make the datepickers always show, instead of showing upon clicking the inputs? The current code only show enddate‘s datepicker, and it will hide when I click the other input.

(2) How to set default date for each, and display the date in the input? The current code doesn’t work.

=== HTML ===
<input type="text" id="startdate">
<label for="startdate">Start date</label>
<input type="text" id="enddate">
<label for="enddate">End date</label>

==== JS ====
$('#startdate, #enddate').datepicker({
    maxDate: 0
});    
$('#startdate').datepicker({
    defaultDate: -30
});
$('#enddate').datepicker({
    defaultDate: 0
});
$('#startdate').datepicker('show');
$('#enddate').datepicker('show');
  • 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-28T02:45:29+00:00Added an answer on May 28, 2026 at 2:45 am

    Based on some tinkering, here’s what I’ve come up with. Granted, i use data attributes to keep the information bound to each object, but you can manage the properties however you see fit (including calling .datepicker on each element individually with the preferences you want).

    With that said:

    <table>
        <tr>
            <td><input type="text" name="startdate" id="startdate" /></td>
            <td><input type="text" name="enddate" id="enddate" /></td>
        </tr>
        <tr>
            <td><div class="date" data-altfield="#startdate" data-defaultdate="-30d"></div></td>
            <td><div class="date" data-altfield="#enddate" data-defaultdate="+0d"></div></td>
        </tr>
    </table>
    
    $(function(){
        $('.date').each(function(i,e){
            var $d = $(this);
            $d.datepicker({
                altField: $d.data('altfield'),
                defaultDate: $d.data('defaultdate')
            });
        });
    });
    

    The above code results in the desired result (or so i can tell).

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

Sidebar

Related Questions

How can i achieve this using jQuery. I have two text inputs on the
I am using jQuery datepicker, I have two datepicker input fields, like following: <html>
I'm currently working with jQuery and using the datepicker. I have two input fields:
I have two inputs, and I have attached jQuery UI Datepickers to both of
Hello I have two text inputs which get their values from a datepicker. What
I have two inputs (text fields) required by JQuery Plug-in : <input type=text name=first_name
I have two inputs which take a date such as 11/04/2010 (im using a
I've been trying to write Jquery code to check if two inputs have the
i have two text inputs like the following, i don't want to use <form>
I have an I2C device that wants two inputs: a denominator and a numerator.

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.