timepicker-bootstrap : easily paste dates into the input field

When the multiselect option is set to true, I am encountering an issue where copying and pasting values from one input field to another triggers a validation event that displays the current day on the selection widget. Despite setting the forceParse option to false, the problem persists.

I have searched through the documentation but have not found a specific solution for this issue. Should I consider forking the package and modifying the paste event myself? There are numerous forks of this package on Github, so perhaps someone has already encountered and addressed this problem before?

https://github.com/uxsolutions/bootstrap-datepicker

Thank you all for your assistance and insights!

$('.date').datepicker({
   multidate: true,
   format: 'yyyy-mm-dd',
   orientation: 'bottom',
   language: 'fr',
   forceParse: false,
});

Answer №1

Solution using the paste event

Problem: https://github.com/uxsolutions/bootstrap-datepicker/issues/1950

$('input').datepicker({
  multidate: true,
  format: 'yyyy-mm-dd',
  orientation: 'bottom',
  language: 'fr',
  forceParse: false,
});

$('input').on('paste', function(e) {
  this.value = new String(e.originalEvent.clipboardData.getData('text') || '')
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.standalone.min.css" integrity="sha256-jO7D3fIsAq+jB8Xt3NI5vBf3k4tvtHwzp8ISLQG4UWU=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js" integrity="sha256-bqVeqGdJ7h/lYPq6xrPv/YGzMEb6dNxlfiTUHSgRCp8=" crossorigin="anonymous"></script>

<input type="text">

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

Creating a see-through backdrop using three.js

I am facing an issue with setting a transparent background to the canvas using three.js. My code is: Background.renderer.setClearColor(0xffffff, 0); However, the background turns black instead of being transparent. How can I make it transparent? Here is ...

display a dialogue box when clicked, containing radio buttons

I am currently developing a practice exam for students at my school. The exam consists of multiple choice questions, and I have hit a roadblock in the coding process. Being new to javascript, I am struggling to figure out how to make it function properly. ...

Updating content on a webpage via AJAX request without altering the original source code

Within the body of our document, referred to as "form.php," we have the following components: At the head section, there is a JavaScript code block: <script> function showUser(str) { if (str == "") { document.getElementById("txtHint").i ...

Swap Text/Characters When Hovered Over

I'm looking to add a fun interactive element to my webpage where the letters in certain text rearrange when a user hovers over it. For instance, hovering over "WORK" would display "OWKR" instead. I have a feeling that some JavaScript is needed for thi ...

What is the best way to retrieve the value of the hidden fields once the radio button has been selected?

I am currently attempting to retrieve the value of the hidden input fields each time a radio button is clicked. The code provided shows a single div structure, but there are multiple divs with the same structure. While I have been able to successfully ca ...

Executing a function after the completion of another

Here is my function: function functionName($results) { //do some stuff disableSave() } When this function runs, I want to call the enableSave() function. How can I achieve this? I attempted to pass the function as a callback but I am unsure wher ...

Absence of receiving any HTTP error codes when making REST calls

In our application, it is crucial to differentiate between 400 and 500 range error codes for distinct processes. Let's consider three REST calls: The first returns a status code of 200, the second returns 401, and the third returns 502 Initially, ...

When implementing afui and jQuery on PhoneGap, an error was encountered: "TypeError: Cannot read property 'touchLayer' of object function (selector, context)"

While working on deploying a web application using phonegap with afui (Intel Appframework UI) for Android, I encountered an issue when testing it in the android emulator. The debug console displayed the following error right after launching the app: Uncau ...

Using Angular's built-in dependency injection with the $resource factory allows for

Question regarding Dependency Injection on factory resource: As far as I know, the following example is the recommended approach for injecting dependencies in Angular1: angular.module('myApp').factory('Resource', Resource); Resource. ...

Setting the initial date value for an Angular Material md-datepicker to a specific date

When using Angular Material md-datepicker, by default the system's current date is set as today's date and highlighted in the calendar. However, I am looking for a way to manually set any given date as today's date instead. Please see this i ...

Designing a circular pie navigation interface using HTML that draws inspiration from the sleek and intuitive pie navigation found

I am on a quest to create a unique pie navigation for my website, inspired by the design seen in Paranoid Android. When the navigation button is clicked, I envision the pie expanding with the first set of menus fading the background like a lightbox. Upon ...

Enhance results by combining data from user input with data retrieved asynchronously from server-side APIs

In the process of developing a web application, I am facing a challenge. There is an input field where users can enter a number and next to it, I want to display the double of that number as the output. While this can be easily achieved using client-side J ...

Is there a way to execute a command with administrator privileges using the Visual Studio code terminal?

In the latest version 1.2.0, a terminal has been added. However, I am facing an issue when trying to install packages using Node.js. Every time I encounter the error message "npm ERR! code EPERM", which I usually resolve by running it as administrator. How ...

Could the act of one function updating state and another immediately accessing it lead to a potential race condition occurring?

I am faced with a scenario where I have two components - one for uploading files and the other for submitting a form. Each component has its own callback function that needs to trigger a backend request once completed. My objective is to ensure that the ba ...

Is it possible to include HTML in a response when verifying emails with Node JS and Angular?

Before diving in, I want to make it clear that I have experience using APIs created in NodeJS with Angular. However, I am encountering a bit of a challenge. The issue at hand involves a function that verifies the email used during registration: exports.co ...

Utilizing static classes in Express: A guide

As a newcomer to the realm of JavaScript, I am eager to develop a web application using the MEAN stack. To maintain some level of organization in my files, I intend to encapsulate all MongoDb-related operations within a static class and call it from my ap ...

Changing text on a button with JavaScript toggle functionality: A step-by-step guide

I am looking to implement a feature where I can hide and show overflow content in a div. When I click on the expand button, it expands the content. However, I want this button to toggle and change text as well. Thank you! function descriptionHeightMo ...

What is the best way to retrieve the title element from a loaded iframe?

Looking for a way to create a dynamic title for my iframe without manually coding it in. My goal is to extract the src of the iframe, load that object, and then retrieve the title element from it. I attempted using iframe.contentDocument but encountered ...

Multiple buttons are linked to a function, causing the sharing of internal variables

I have a situation where I need to bind ajax calls to multiple buttons, each button being unique based on attached data attributes. The issue arises when the internal variables of the function are shared among different buttons. This leads to problems if ...

How to extract a section of a string with AngularJS

Can someone help me figure out how to remove the last part of a string in order to obtain just the main word? For example, turning string(1) into string. Any suggestions would be appreciated! PS. Note that the string might look like this: sringggg(125). ...