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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:08:59+00:00 2026-05-26T19:08:59+00:00

I am using the jQuery UI plugin with the Datepicker function, to set a

  • 0

I am using the jQuery UI plugin with the Datepicker function, to set a date range. The example provided on their page (http://jqueryui.com/demos/datepicker/date-range.html) sets the range based on input ‘id’; however, I’d like to set the range based on ‘class’ as my form ‘clones’ the div to add additional inputs, making the ‘id’ fields unique on each clone. When I change the JavaScript to use ‘class’ instead of ‘id’, the ranges are no longer functioning.

JavaScript:

<script src="../../scripts/jquery-1.6.4.js"></script>
<script src="../../scripts/jqueryui/ui/jquery.ui.core.js"></script>
<script src="../../scripts/jqueryui/ui/jquery.ui.datepicker.js"></script>
<script>
        $(function() {
            var dates = $( ".start_date, .end_date" ).datepicker({
                onSelect: function( selectedDate ) {
                    var option = this.class == "start_date" ? "minDate" : "maxDate",
                        instance = $( this ).data( "datepicker" ),
                        date = $.datepicker.parseDate(
                            instance.settings.dateFormat ||
                            $.datepicker._defaults.dateFormat,
                            selectedDate, instance.settings );
                    dates.not( this ).datepicker( "option", option, date );
                }       
            }); 
        });
</script>

HTML:

<div>
    <label> Start Date:</label>
    <input type="text" name="start_date1" id="start_date1" class="start_date" />
</div>
<div>
    <label> End Date:</label>
    <input type="text" name="end_date1" id="end_date1" class="end_date" />
</div>
  • 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-26T19:08:59+00:00Added an answer on May 26, 2026 at 7:08 pm

    To check to see if your element has a class, do this:

     if ($(this).is('.start_date')) {
    

    or

     if ($(this).hasClass('start_date')) {
    

    The name of the property of DOM elements is “className”, not “class” (confusingly). Also it makes your code fragile to check for the class name to be equal to some string, because you never know if you might want to add another class (like “required” for example). Thus you should always check either with jQuery or with some other method that accounts for the possibility that an object can have many classes.

    Also you may want to check out the Filament Group’s date range picker for jQuery.

    • 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 Date Picker plugin by Kelvin Luck ( http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ ) and
I'm using the jquery datepicker plugin at http://plugins.jquery.com/project/datepick with the datepicker validation plugin. <script
I'm using the jquery datepicker plugin to set a date field that is stored
I am using jquery lightbox plugin colorbox ( http://colorpowered.com/colorbox/ ) and i want to
I have a form which is built dynamically using this jQuery plugin http://code.google.com/p/jquery-dynamic-form/ When
well im using this script right here: http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ and I have a multiMonth plugin
I'm using this jQuery inline datePicker plugin sample but I don't know how to
I am using the jquery validation plugin from: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ How can I add a
I am currently using the JQuery plugin Datepicker in my Symfony project with the
i'm using successfully a jquery datepicker with masked input plugin too in a aspx

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.