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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:37:42+00:00 2026-05-23T02:37:42+00:00

We have a textbox that we want to both trigger a jQuery UI datepicker,

  • 0

We have a textbox that we want to both trigger a jQuery UI datepicker, as well as have the ability to enter text freehand into the textbox. We are currently achieving this is with both jQuery UI Mask & DatePicker on the same textbox. However, I had to ‘hack’ the mask to get it to work – because, once you freetext enter: 04/29/19

Then, before you can finish entering the “83” to finish the four digit date, datepicker fires some event that moves the datepicker’s current date to the one you are entering, but, it also deletes the entire date so far. So the goal was to enter the date: 04/29/1983, but the datepicker deleted what I had so far. At first we thought the mask was at fault, but now I just need to figure out how to kill the datepicker event from firing mistakenly. Any help would be so appreciated!

Sorry, code sample:

$('#txbxSocialHistoryDate').datepicker({
        showButtonPanel: true,
        changeMonth: true,
        changeYear: true
 });

$('#txbxSocialHistoryDate').mask("99/99/9999", { placeholder: " " });  
  • 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-23T02:37:43+00:00Added an answer on May 23, 2026 at 2:37 am

    The above answer definitely works for this question. However, without a trigger button, I came up with a solution, as follows:

    $('#txbxSocialHistoryDate').datepicker({
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                dateFormat: 'mm/dd/yyyy',
                onSelect: function (dateText, inst) {
                    UIUtilities_jQueryDatePickerOnCloseEventIfAlsoMasked(this, 'txbxSocialHistoryDate', dateText);
                },
                onClose: function (dateText, inst) {
                    UIUtilities_jQueryDatePickerOnCloseEventIfAlsoMasked(this, 'txbxSocialHistoryDate', dateText);
                }
    });
    
    $('#txbxSocialHistoryDate').mask("99/99/9999", { placeholder: " " });
    
    function UIUtilities_jQueryDatePickerOnCloseEventIfAlsoMasked(thisDatePicker, txbxOfDatePicker, dateText) {
        // when the calendar closes, determine if this was entered by hand, or by the calendar
        var textInBox = $('#' + txbxOfDatePicker).val();
    
        // if by the calendar, it will have 2 years attached, so we then shave the 2nd year off the end
        // there is a brief flash of the incorrect year, but short of taking off both the masking & calendar on this one textbox, this will work...
        if (textInBox.length > 10) {
            $('#' + txbxOfDatePicker).val(dateText.substring(0, dateText.length - 4));
        }
    
        // this fixes the tabbing issue mentioned; now when you tab out of the calendar, it will move on to the appropriate control...
        thisDatePicker.focus();
    }
    

    So what I did:

    • Declare the datepicker, but make the format: ‘mm/dd/yyyy’, which, I mistakenly believed to be what it appears. However, on the jQuery DateFormat definition site, this actually makes the date, when selected, be formatted as: mm/dd/yyyyyyyy (year repeats twice). ‘yy’ == 4 digit year in DateFormat, apparently.
      This initial mistake led me to the answer.
    • Mask the date field in question that you have already bound your datepicker to.
    • With a longer date entry, the event that fires that was deleting my mask is stopped. All I had to do was put in this custom method that I created on the datepicker’s onSelect & onClose functions, & now everything works. It essentially strips off the double year that is unnecessary & incorrect from the datepicker’s selection. Masking & the datepicker with a 4 digit year format now work together.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox that I want the user to enter an integer in.
I have a windows forms app with a textbox control that I want to
I have a user that want to be able to select a textbox and
I'm creating a login page. I want to create ASP.NET TextBox controls that have
I want to have a text box that the user can type in that
I have an HTML textbox that contains some SQL code that I need executed.
I've got a multiline textBox that I would like to have a label on
If I have .Net Form with a component/object such as a textbox that I
I have an extender control that raises a textbox's OnTextChanged event 500ms after the
I have a composite control that adds a TextBox and a Label control to

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.