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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:06:17+00:00 2026-06-14T03:06:17+00:00

Is there a way to get the current value from a date input field

  • 0

Is there a way to get the current value from a date input field in the keypress event? I have used the jQuery .val() function or the straight javascript .value on text input fields in the keypress event without difficulty, but when I try either of these on a date input field (in a browser that supports it, such as chrome), I just get an empty string – apparently the value isn’t set until a valid date is entered.

I’m using this functionality to allow a user to enter a date as just six digits, such as 110712, and automatically adding the slashes as they type to make 11/07/12. I could, of course, just use a plain text input, but I like the pop-up date picker the date type field gives me on browsers that support it.

EDIT:
Perhaps I wasn’t clear about what I was trying to do. From within the keypress handler attached to a date input field, I want to get what the user has currently typed in the field. For example, if the user has already typed “11” and then types a “0”, I want to be able to see that the current value of the field is “11”. With a basic text input (or a browser not supporting date input fields), I can call .val() or .value from within the keypress event handler and it will give me a result of “11”. In a browser that supports date input fields, however, all I get when calling val() or .value is “”.

  • 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-14T03:06:19+00:00Added an answer on June 14, 2026 at 3:06 am

    Update:

    Unfortuantely, it would appear that this cannot be done. Consider the input[type=”date”] a select where the options are every date in history, rather than a textbox.
    http://www.html5tutorial.info/html5-date.php
    The above link shows other browsers implementing it exactly this way. Notice that as soon as your textbox has a valid date, .val() gets that value.

    you could accomplish a hybrid using both an input[type=”text”] and a small input[type=”date”] next to it that dumps its value into the textbox on change.

    Working example: http://jsfiddle.net/WaAcU/ (this doesnt do your validation, just dumps the selector into a textbox)

    Original Answer:

    use the JQuery keypress handler.

    $(dateField).keypress(function(){
        ...your validation code...
    });​
    

    trivial example:
    http://jsfiddle.net/zUMHr/

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

Sidebar

Related Questions

is there way how to get name ov event from Lambda expression like with
Is there a way to get HTML contents from TinyMCE editor using jQuery so
Is there a way to get the current content of a WebView? What about
Is there any way for me to get at a UITextField's current caret position
Is there way to get file from windows xp command prompt? I tried to
I have a custom UserType which stores a date/time value in a TIMESTAMP field
Is there a way to get the current xml data when we make our
Is there a way to get the item pointed at by an iterator in
Is there a way to get distance between two objects in meters? I'm trying
Is there a way to get the path to where WordPress is installed? I

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.