Tips to prevent the issue of multiple datepickers displaying in Google Chrome

When I first implemented the date form input without the "datepicker" class, it worked fine in Google Chrome but not in Firefox. So, I decided to add the class along with its associated scripts and styles. This fixed the issue in Firefox, but now two datepicker widgets show up in Google Chrome causing confusion as the jQuery datepicker widget cannot be used as intended.

Below is a snippet of my code:

<div class="form-group">
    <label class="control-label col-sm-2">Tanggal lahir :</label> 
        <div class="col-sm-10">
            <input type="date" class="form-control datepicker" name="tglLahir">
        </div>
</div>
<link rel="stylesheet" type="text/css" href="../js/jquery-ui.css">
<script type="text/javascript" src="../js/external/jquery/jquery.js"></script>
<script type="text/javascript" src="../js/jquery-ui.js"></script>
<script type="text/javascript">
    $( ".datepicker" ).datepicker();
</script>
</div>

Screenshot :

Apologies for any language errors.

Answer №1

As per the information from caniuse (http://caniuse.com/#feat=input-datetime), it has been noted that the input type "date" is not fully functional on Firefox, which explains why you might encounter a double datepicker on Chrome (the first one being the default picker within the browser and the other from jquery datepicker).

To address this issue promptly, a quick fix would be to switch type="date" to type="text".

Update: Alternatively, without altering the input type, you can apply the following CSS rule:

input[type=date]::-webkit-inner-spin-button, input[type=date]::-webkit-calendar-picker-indicator {
   display: none;
}

This essentially hides both the spin button and the picker indicator, preventing the activation of the native datepicker.

Answer №2

To switch the input field from type="date" to type="text" is recommended.

The reason for this change is that Google Chrome automatically detects type="date" and provides a built-in date picker for user convenience.

As an alternative, you can either make the modification as mentioned or delete the datepicker code altogether. By removing the datepicker code, you will have <input type="date"> remaining. However, keep in mind that in browsers such as Firefox that do not support the native date picker feature, the date input field may not display correctly.

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

Encountering an issue with AJAX form submission in PHP when integrating object-oriented programming principles with Sweet Alert confirmation pop-ups

I am looking to enhance my form submission process by incorporating AJAX jQuery and adding a sweet alert confirmation before submitting the form. Currently, the form functions correctly without any AJAX or JavaScript; however, I want to improve the user e ...

Tips for managing pop-ups and cookies using selenium

Encountering an issue while trying to scrape the MorningStar website using Chrome Selenium. Upon visiting the webpage, a pop-up appears prompting to confirm if I am an individual investor (related to cookies). Closing this pop-up by locating and clicking t ...

Exploring Real-Time Search Functionality in Flask with Bootstrap Forms and Jinga2 Templates

How can I implement a live search feature in my Flask application using WTForms/Jinja2 to mimic the functionality described here? The code snippet provided already has an example working for the third box, but I'm struggling to adapt it to work with m ...

Why is it that vanilla HTML/JS (including React) opts for camelCase in its styling conventions, while CSS does not follow the same pattern

Each type of technology for styling has its own set of conventions when it comes to naming properties, with camelCase and hyphenated-style being the two main options. When applying styles directly to an HTML DOM Node using JavaScript, the syntax would be ...

Identify the mistake - Combining: php pdo (fetch object), json, and jquery.post()

Seeking assistance from someone more experienced than me to identify the problem. I am struggling to debug it as my var_dumps do not seem to have any effect, possibly due to the use of jquery.post(). I am not getting any output displayed. I was anticipati ...

What is the encoding for Javascript in UTF-8?

My current ajax call is able to successfully send the request and retrieve the expected response. However, I am facing difficulty in correctly displaying it in li items. $.ajax({ url: "{% url 'users:profile_page_tags_get' 'primary&apos ...

Incorporating a class into a jQuery object that has been sent to a function

I'm dealing with a jQuery function that is supposed to add a class called .dataerror to different HTML elements if they are empty. Initially, I have this code snippet: $('.editable').each(function() { if (!$(this).html()) { show ...

Generate a new document and input information using the ionic framework

I'm currently working on an application for mapping purposes. I have generated KML and JSON strings that need to be stored in files within the phone's memory. To achieve this, I implemented the following code: var fileObject; document.addEve ...

Can you explain the significance of this HTML code?

While examining some source code, I came across the following: <div class="classname {height: 300px; width: 200px}"></div> I am aware that element styling can be done using the style="" attribute. Could you explain what this code snippet sig ...

minimize the overlay for the full-screen menu

I have a fullscreen menu overlay with a close button, but I want to be able to close the overlay by clicking anywhere outside of the menu on the overlay itself. How can I achieve this functionality in my code? (function() { var triggerBttn = documen ...

Exposing a Hidden Division with a Link via jQuery

I currently have a jQuery Panel set up to open when clicking a button. Now, I am looking to add a second link at the bottom of the page that will also open the same panel. Can anyone provide guidance on how to accomplish this? You can view my JSFiddle a ...

Persistent header feature in AdminLTE 3: Easily navigate while scrolling

I am looking to make the elements in the red box on the left side of the page fixed so that as users scroll, they remain at the top of the page. I have attempted to use both the fixed and sticky properties, but neither seem to be working for me. Here is a ...

Expanding a position absolute container beyond a overflow-hidden container

It's been a few months since I last worked on CSS, so I might be overlooking something simple. I've been struggling to find a solution to my problem, no matter how hard I try. Here is the issue: Below is a simplified version of my code: <div ...

Struggling to get the HTML layout just right on my MVC 5 Razor Page with Bootstrap CSS

I am currently facing difficulties aligning elements and displaying them in the same row. I am using MVC 5 razor pages along with HTML and Bootstrap.css. Despite spending several days on it, I have only made minimal progress since I started. I will provide ...

The circles seem to be elusive, refusing to make an appearance on the forefront of the HTML webpage

My scatterplot circles appear to be behind the graph, and I can't figure out how to bring them to the front. Can anyone help me with this issue? Even though the inspection shows that the circles are there, they are not visible on the plot. scatterplo ...

What is the easiest method to design an email subscription form that remains fixed on the top right corner of the screen?

Looking for advice on setting up a sleek email signup bar that remains at the top of the browser while users scroll and navigate through different pages. I am working with WordPress and have jquery already loaded, but have not yet worked with either. Up ...

Counting the number of characters without including HTML tags in C#

I am currently exploring methods to calculate the number of characters in a string, shorten the string, and then return it without including HTML tags in the character count. It's important that HTML tags are not counted because if the truncation poin ...

Find the position of inputs with non-numeric indexes in an array using Jquery

I am working with inputs that have non-numeric indexes using jQuery: <input name="attributes['index1']" class="text_inputs" /> <input name="attributes['index2']" class="text_inputs" /> <input name="attributes['index ...

Facebook is failing to detect any meta tags in the header of my React web application

After checking my code on https://validator.w3.org/, everything seems fine. However, I noticed that Facebook is not reading most of the content from the head section - not even a single meta tag. On the other hand, Google is able to read all the content fr ...

Conceal element with transparent overlay without affecting the background

Looking to add animation to a snippet where the login menu rolls out? Consider two methods: adjusting the left position of the login menu or using another div on top to slowly reveal the login menu after moving it. The challenge lies in maintaining trans ...