Enable only the current week days on the multiple date picker feature

Can anyone recommend a date picker that only shows the current week and allows for multiple date selections by the user?

I found this jsfiddle which limits the display to the current week, but it doesn't support selecting multiple dates.

I attempted to use the multidate:true option, but it wasn't successful. Is there another way to achieve this functionality, or is it simply not possible? I need to make a decision soon.

I've been working on this for a week now without any luck.

Here's the JavaScript code I've tried:

 $(function () { $('.pickWeek').datetimepicker({
    multidate:true,
    locale: 'pt-br', 
    format: "DD/MM/YYYY", 
    sideBySide: true, 
    daysOfWeekDisabled: [0] }); 
    $('.pickWeek').data("DateTimePicker").minDate(moment().startOf('week'));
$('.pickWeek').data("DateTimePicker").maxDate(moment().endOf('week')); });

Answer №1

If you're having trouble with the bootstrap datetimepicker plugin, consider switching to the bootstrap datepicker plugin instead.

$(function () {        
        $('.pickWeek').datepicker({
            locale: 'pt-br',
            format: "dd/mm/yyyy",
            sideBySide: true,
            daysOfWeekDisabled: [0],
            multidate:true,
            startDate:moment().startOf('week').toDate(),
            endDate:moment().endOf('week').toDate()
        });
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/css/bootstrap-datepicker.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/locale/pt-br.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/js/bootstrap-datepicker.min.js"></script>

Multiple Date Selection
<div class="form-group">
    <div class='input-group date pickWeek'>
        <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
        </span>
        <input type='text' class="form-control" />
    </div>
</div>

I have included both examples on jsfiddle for you to test its functionality here

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

No data returned in AJAX response while trying to connect to a RESTful service

After creating a WCF REST service that returns a JSON response like {"Id":10,"Name":"Peter"}, I noticed that when trying to access it using the provided HTML5 code snippet, the status returned is always 0. Can anyone help me figure out what might be caus ...

Using JQuery to Identify the Clicked Div Container

Currently working on a JQuery script to determine which specific div box was clicked, but running into some issues. I understand that there are other approaches to achieve this by directly invoking functions upon clicking a div box, but I want to first ide ...

Adjust the height and eliminate gaps between rotated divisions

I'm currently working on a floating menu that includes several links. I've successfully applied a CSS style to rotate the menu vertically (-90deg), but I'm facing an issue with the height being greater than desired. How can I reduce the heig ...

What is causing the issue with the "Inline-block" property in this CSS code?

Please review the CSS code provided below for styling instructions. /*rex is the container of ex,ex2,ex3*/ div.rex{ height:200px; border:0px; margin:60px auto; padding: 0; vertical-align:top; } div.ex{ width:34%; height:200px; background-color:#4f443a; ...

Developing a fresh Outlook email using a combination of javascript and vbscript

I have created a custom HTML page with fields and a button to fill out in order to generate a new Outlook mail item. To format the body of the email using HTML, I am utilizing VBScript to create the new mail item. <script> function generateEmail() { ...

When using res.redirect in Express, it not only redirects to a new URL but also allows you to access the HTML

I'm having an issue with redirecting a user to a login page when they click a button. Instead of being redirected, I am receiving the html source code and nothing is happening. My express redirect method is as follows: function customRedirect(req, ...

Listing the dates of the month and comparing them with dates from another month using jQuery

Is there a way to generate a list of dates in a month that includes the dates from other months, similar to how the jquery datepicker with showOtherMonths: true works? I was considering creating a calendar with 7 columns (Sun-Sat) and 6 rows to accommodat ...

Steps for displaying the contents of a file from Firebase storage on a React component

I uploaded a file to Firebase storage, and I want my app to be able to access and display the contents of that file within my class component div. Currently, when I try to access the file, it just opens in a new tab instead. class ScanResult extends Comp ...

Performing read and write operations on targeted CSS classes using C#

I'm currently developing a C# application that needs to manipulate CSS files. Imagine you have the following CSS code snippet: .ClassOne { color: #FFFFFF; font-weight:normal; font-size: 9pt; font-family: Tahoma; ...

Sending a text parameter to the JavaScript Executor within a Selenium framework

Although this question has been asked before, I have searched for multiple answers and have not found a solution to my specific problem. if (driver instanceof JavascriptExecutor) { System.out.println("In try"); ((JavascriptExecutor)driver) ...

Customize your Google Translate experience by choosing your own option values

Is there a way to trigger the same JavaScript calls by clicking on an option value in an HTML select element as with text-based links in the Google Translate widget? Check out this jsfiddle for more information <html> <body> <select i ...

A guide on displaying data dynamically in Laravel with jQuery without the need for a page refresh

I am eager to fetch data from the database without having to reload the page. Currently, I am utilizing Laravel for this task and have been able to successfully retrieve the data using jQuery. Below is a snippet of my jQuery code: function fetchData() { ...

tips on customizing buttons within form groups

I have set up two separate form-groups: My goal is to click on each button within each group and toggle its style from grey to green, and vice versa. However, when I click on a button, all buttons within the group turn grey except for the one that was cli ...

Error: Unable to locate sportsRecord due to missing function

updated answer1: Greetings, I have updated the question with some detailed records and console logs for better understanding. sportsRecord = { playerTigers:[ {TigerNo: 237, TigerName: "Bird Bay Area", TigerkGroupNo: 1, isDefault: true ...

Ways to automatically adjust the margins of my HTML body page

I'm currently working on a school project to develop a website. The challenge I'm facing is customizing the navbar and header background colors in such a way that they extend seamlessly to the end of the page. Despite my efforts, there seems to b ...

My JavaScript code is functioning properly in jsfiddle, but when I try to run it on my own website, I encounter

Encountered an error message stating "Uncaught typeError: cannot call method 'hover' of null" following the line $('#nav li a').hover(function(){ in my JavaScript code. Check out the code on my site here: http://pastebin.com/GjZBEu3s Y ...

Creating dynamic HTML elements using ngFor within AngularJS allows for increased flexibility and customization on the

I'm a newcomer to Angular 5 and I'm looking to retrieve HTML elements from a .ts file and dynamically add them to an HTML file using ngFor. I attempted to use [innerHtml] for this purpose, but it was not successful and returned [object HTMLSelect ...

Using JavaScript to convert an image URL to a File Object

Looking to obtain an image file from a URL entered into an input box, leading to the transformation of an image URL into a file object. To illustrate, when selecting a random image on Google Images, you can either copy the Image or its URL. In this scena ...

Executing a Node.js program using the command line without having to type out the word 'node'

I am currently working on a Node.js package that includes a command-line utility. Right now, alacon.js is situated in the root of the package. To execute this utility, I have to use the word node followed by the utility's name, like so: node alacon ...

IE11 retains radio button selection even after page reload

I am facing an issue on my webpage where I have implemented radio buttons for filtering a list. ALL (default selected with checked='checked') MATCHED REST <input type="radio" value="ALL" name="options" class="radioStyle" checked autocompl ...