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

The Archive Base Latest Questions

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

In chrome, a tag like <input id=picker type=date> renders as a text field. However,

  • 0

In chrome, a tag like

<input id="picker" type="date">

renders as a text field. However, calling trying to get its value with something like

$("#picker").val()

returns nothing until a valid date is entered or picked from it’s dropdown.
I took a look at all of the object’s immediate properties on a keypress with

$("#picker").keypress(function() {
    var output = ""
    for (var i in this) {       
        output += i +" value:"+ this[i] + "\n";
    }
    alert(output);
});​

but couldn’t see my input in any of these. Check for yourself at http://jsfiddle.net/5cN2q/

My question is: Is it possible to get the text from a input[type=”date”] in chrome when the input is not a valid date?

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

    The W3C Date State spec defines the sanitization algorithm:

    • The value sanitization algorithm is as follows: If the value of the element is not a valid date string, then set it to the empty string instead.

    Which is invoked whenever setting the value of the input element, as defined in DOM input value spec:

    • On getting, it must return the current value of the element. On setting, it must set the element’s value to the new value, set the
      element’s dirty value flag to true, invoke the value sanitization
      algorithm
      , if the element’s type attribute’s current state defines
      one, and then, if the element has a text entry cursor position, should
      move the text entry cursor position to the end of the text field,
      unselecting any selected text and resetting the selection direction to
      none.

    So the value property will always be an empty string when the date is not valid. There doesn’t seem to be any property for “original/dirty/user-typed text value” specified as it is not a text input after all.

    IMO it is a good thing, it facilitates form validation as invalid dates are treated as falsy values (empty strings), it also leaves browsers to more freely implement the UI for date inputs.

    If you prefer a non-W3C date input, you can use a text input with the good old JS date validation and a datepicker, such as the jQuery UI datepicker. This would allow you to retrieve the actual text value of the input and is a much more cross-browser solution as well.

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

Sidebar

Related Questions

Chrome v4 supports the placeholder attribute on input[type=text] elements (others probably do too). However,
I'm trying to get HTML5's audio tag to work in Chrome. The following code
HTML code: <input id=txtSizeBeforeValue type=text size=5 value=blabla> <input id=txtValueBeforeSize type=text value=blabla size=5> HTML parsed
I'm trying to create a video tag for use with Chrome only. I don't
I want to auto select a file through File input tag < input type=file
<form id=search action=/search method=get autocomplete=off> <div> <input type=button name=test_button value=test /> </div> </form> <script>
I'm trying to get the first image tag on a page. The regular expression
I try to do something like that 1. <head><% out.println(<script type=\text/javascript\>); out.println(function myfunction(){); out.println(for(int
So Chrome is here for iOS.. Hoorah! However now due to the different screen
I'm trying to take the scroll bars out of an <object> tag in HTML.

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.