Using the HTML date picker on an Android device for manually inputting dates

The built-in date picker:

<input type="date">

on my Android device (Google Pixel 4a running Android 11) does not give me the option to manually enter the date. Each time I try to input a date, the date picker appears instead of the keyboard.

Is there a method to enable manual typing using the keyboard for this field?

Answer №1

Is there a way to permit manual typing using the keyboard?

As of now, there is no direct way.

However, you can implement a combination of pattern, minlength, and maxlength attributes:

The date pattern details are explained here, and you can test regex patterns on regex101

var custom_input_date = document.getElementById('customInputDate');
custom_input_date.oninput = function(event){event.target.setCustomValidity('');}
custom_input_date.oninvalid = function(event) { event.target.setCustomValidity('Use a valid format: dd/mm/yyyy'); }
<form>
<input id="customInputDate" type="text" pattern="^(?:(?:31(\/)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$" maxlength="10" minlength="10" autocomplete="off" placeholder="dd/mm/YYYY" required>
<input type="submit">
</form>

Answer №2

You could try the following solution:

<!DOCTYPE html>

    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script>
      $( function() {
        $( "#datepicker" ).datepicker();
      } );
      </script>
    </head>
    <body>
     
    <p>Try entering a date here: <input type="text" id="datepicker"></p>
     
     
    </body>
    </html>

Some HTML elements may behave differently based on the browser or device being used. The code above should work in most cases. If not, consider looking into frameworks that can assist with this issue. It's also worthwhile to explore similar questions and solutions that have been shared by others. Here is another related query you might find helpful: How to trigger the native datepicker on Android using the HTML5 input type 'date'?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why does the URL keep adding the link every time I click on an "href" link?

I have a button labeled <a href="home.jsp">Home</a> and another link <a href="CRUD/Books/Add.jsp">Add</a> If I click on Home and then Add, everything works fine. However, if I click on Add again, the URL starts to multiply like ...

Tips on altering button color when input field is populated

I have been researching online and have not come across any discussions on how to dynamically change the color of a button in JavaScript when an input field is filled. I haven't really tried any code myself because there are very limited resources add ...

Tracing a path with a snapping motion using my thumb

Before we begin, let's take a look at the example below. The functionality of this component should mimic that of an input type range. However, I am facing some challenges in calculating the step value and snapping the thumb onto the trail based on t ...

Setting the borderRadius for a web view on Android Maps V3: A complete guide

In my application, I am using Android Map V3 and have encountered a bug specific to the Kit-Kat version. The chromium kit throws up an error message - nativeOnDraw failed; clearing to background color, which prevents the map from being displayed. Despite ...

Title: How to Build a Dynamic Logo Carousel with React and CSS without External Dependencies

Currently, I am in the process of integrating a logo carousel into my React web application using CSS. My goal is to create a slider that loops infinitely, with the last logo seamlessly transitioning to the first logo and continuing this cycle indefinitely ...

Is it possible to make the mat-menu-item the same size as the mat-menu button in Angular Material v.12?

How can I ensure that the mat-menu-item button is the same size as the mat-menu itself? For example, click here <div class="container d-block d-md-none"> <div class="row"> <div class="col d-flex justify-content-cent ...

How to emphasize a portion of an expression in AngularJS using bold formatting

I have a specific goal in mind: to emphasize part of an angular expression by making it bold. To achieve this, I am working with an object obj which needs to be converted into a string str. obj = $scope.gridOptions1.api.getFilterModel(); for (var pr ...

Having two ng-click events and two distinct classes in an ng-repeat based on the selected option

There are two buttons in my code that should remove a div within an ng-repeat loop. Depending on which button is clicked, a custom CSS class should be added to the effect. The CSS changes based on the option selected. When I click on a button, either &apo ...

Discover the steps to incorporating events that enable page transitions for a dynamically generated listview using jQuery Mobile

By utilizing the following code snippet, I successfully inserted data into the listview: var renderItemElement = function(item) { return $.tmpl("<li><a>${text}</a></li>", item) .data("item", item) .insertAfter( ...

sending information stored in an array from an HTML form to PHP variables arranged in an array

I am currently facing an issue with a form designed to track the hours worked on various projects. The form features an array for project ID, hours, and notes fields, with the lines of the form iterating based on the number of projects. However, when passi ...

Unable to use Selenium web driver for C# to choose an element by its tag name

Currently, I am utilizing Selenium Web Driver in C# to interact with Google Chrome browser. However, when attempting to retrieve the inner HTML (text) of a specific element as shown in the provided HTML snippet below, an error message "no such element ...

Add the file to the current directory

As a newer Angular developer, I am embarking on the task of creating a web page that enables users to upload files, with the intention of storing them in a specific folder within the working directory. The current location of the upload page component is ...

There seems to be an issue with the Angular QuickStart project as it is not functioning properly, showing the error message "(

After following the instructions in this guide for setting up VS2015, I encountered issues when trying to run the "quick start" project or the "tour of heroes" tutorial on Google Chrome. The error message I received can be found here: Angular_QuickStart_Er ...

The functionality of elements such as buttons and textboxes has been compromised since they have been placed within a CSS tabbed table

I successfully implemented small tables containing input elements and buttons, but I decided to enhance the user interface by placing them inside CSS tabs. The new layout looked better and saved space on the page. After configuring the CSS tabs using divs ...

How can I position a Button at the center of my Grid item using Material UI?

In my React 16.13.0 application, I am utilizing Material UI's Grid and trying to center the content of a button in the middle of a row. Here is what I have tried: center: { alignItems: "center", width: "100%", }, halfRow: { width: "5 ...

CSS dropdown fix for improved responsiveness

Check out this Fiddle >> http://jsfiddle.net/fpCpc/`"> jsfiddle Having a problem where the top part of the dropdown navigation doesn't stay active when scrolling down. I even captured a screenshot for clarification! Screenshot Any tips or ...

Moving value between different tasks on the to-do list

In the current project scenario, there is a requirement for one activity to pass a value to another. Based on this value, the appropriate menu element needs to be selected. I attempted to achieve this using bundle, however, I am unsure of how to determin ...

What is the best way to resize an iframe containing a video to match the size of its parent

When using CSS, it is possible to stretch and adjust the ratio of an image to fully cover its parent div. The image will also resize accordingly if the parent div is responsive. Is this same effect achievable with videos (iframe) as well? EDIT: I am conce ...

"Creating a 2-column layout for an unordered list using CSS Flex

After spending far too much time at work today pondering this issue, I've decided to turn to the collective wisdom of the internet. My dilemma involves a standard <ul> containing multiple <li> elements (currently 12, but this number could ...

Issue with jQuery's addClass() function not functioning properly on Internet Explorer versions 8, 9, and possibly others as well

Here is some basic HTML code: <div class="stuff-choice"> <div class="item a"> <label class="signup-checkbox"> <input type="checkbox" value="a" name="stuff[a][]" id="stuff_choice_" class="things"> <strong>A&l ...