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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:16:54+00:00 2026-06-15T22:16:54+00:00

All my datepickers have an automatically-generated hidden field which has the same ID as

  • 0

All my datepickers have an automatically-generated hidden field which has the same ID as the datepicker input, but with an underscore prepended.

<div class="datepicker">
    <input id="MyField1" type="text" value="" />
    <input id="_MyField1" type="hidden" value="" />
</div>

<div class="datepicker">
    <input id="MyField2" type="text" value="" />
    <input id="_MyField2" type="hidden" value="" />
</div>

And then any field which has class datepicker gets made into a datepicker.

$('.datepicker input').datepicker({
    altFormat: 'yy-mm-dd',
    changeMonth: true,
    constrainInput: true,
    dateFormat: 'dd/mm/y',
    minDate: '+0d',
    numberOfMonths: 2
});

But how can I also automatically get it to set the altField option for each one?

This doesn’t work. I also tried doing the assignment in the original options but that doesn’t work either.

$('.datepicker input').each(function() {
    var altField = '_' + $(this).prop('id');
    $(this).datepicker('option', 'altField', altField);
});
  • 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-15T22:16:55+00:00Added an answer on June 15, 2026 at 10:16 pm

    The altField option takes a selector, a jQuery object or an element, not an id attribute.

    Try specifying an id selector:

    $(this).datepicker("option", "altField", "#_" + $(this).prop("id"));
    

    Or alternatively, saving a call to $() and a call to prop():

    $(this).datepicker("option", "altField", "#_" + this.id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple datepicker text field: <input type=text name=book_on id=book_on value=<?php echo $today;
I have this code: $('.ui-datepicker-calendar tr').live('mouseleave', function() { $(this).find('td a').removeClass('ui-state-hover'); }); This affects all
I have two datepickers for search parameters but i cant have the search more
I have a weird situation (don't we all?) with datepickers and want to get
I have .change jQuery function. All are working except for one text field. That
I have 4 columns. All these columns have datepickers in top. I want to
I have a DatePicker which I follow changes with dp.init(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), new OnDateChangedListener()
I have two jQueryUI datepickers on my page. They're initialised as below: jQuery(#departureDate).datepicker({ beforeShow:
I have the usual Jquery datepicker working fine. But I want to feed it
I have a partial which loads all common links and styles in head and

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.