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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:55:54+00:00 2026-06-09T11:55:54+00:00

I have two forms with 2 input boxes for inputing start date and end

  • 0

I have two forms with 2 input boxes for inputing start date and end date, markup for this is:

<form>
    <input type="text" id="from1" name="from1" />
    <input type="text" id="to1" name="to1" />
</form>
<form>
    <input type="text" id="from2" name="from2" />
    <input type="text" id="to2" name="to2" />
</form>

I need to set minimum value for input boxes with end date when value in input boxes with start date is changes. When I set datepicker directly like this:

$("#from1").datepicker({
    onSelect: function(selectedDate) {
         $("#to1").datepicker("option", "minDate", selectedDate);
    }
});
$("#to1").datepicker();

that works. But when I set datepicker in loop like this:

for (var i = 1; i < 3; i++) {
    var input1 = "#from"+i;
    var input2 = "#to"+i;
    $(input1).datepicker({
        onSelect: function(selectedDate) {
             $(input2).datepicker("option", "minDate", selectedDate);
        }
    });
    $(input2).datepicker();
}

that doesn’t work, if I select value in the “from1”, “minDate” is set only for “to2”. I would like to set “minDate” for “to1” when I change value in “from1”.
Any idea what is wrong? Thank you in advance

  • 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-09T11:55:56+00:00Added an answer on June 9, 2026 at 11:55 am

    I don’t understand why would you set datepicker on a loop… Use a class instead and it’ll be easier. Also why would you have two forms?

    <form>
        <input type="text" id="from1" class="from" name="from1" />
        <input type="text" id="to1" class="to" name="to1" />
        <input type="text" id="from2" class="from" name="from2" />
        <input type="text" id="to2" class="to" name="to2" />
    </form>
    

    And simply this in JS:

    $(".from").datepicker({
        onSelect: function(selectedDate) {
             $(this).next()
                    .datepicker("option", "minDate", selectedDate);
        }
    })
    // not sure you need this...
    .next()
    .datepicker();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with two input text fields: <input id=ModelName_test_0 name=ModelName[test][0] type=text> <input
I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I have two forms <form name='myform1'> <input type='button' class='submitBtn'> </form> <form name='myform2'> <input type='button'
I have a form containing two text boxes for user input. Both text boxes
I have two forms on one page and want to have the input boxes
In my HTML code, I have a form tag that contains two input boxes,
I have two form fields on my view page, a date input (with a
I have an input form with two textareas allowing a user to type in
I have two buttons on my MVC form: <input name=submit type=submit id=submit value=Save />
I am using jQuery validate to validate a form. I have two text boxes

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.