Restrict the duration of time a user can spend in the v-calendar

I'm currently developing a project where users can request appointments. I'm utilizing the v-calendar library, which incorporates a datepicker.

The challenge I'm facing is that users are able to request appointments at any time of day, 24/7, whereas I need to restrict it to only be available from 9am - 5pm. While I know we can limit the date selection in the date picker with something like :max-date="value", I haven't been able to find a way to limit the time range.

You can view a working example here.

Below is a snippet of code from the project:

    name="appointment-date"
    v-model="appointment_date"
    mode="dateTime"
    :is24hr="false"
    :min-date="currentDate"
    :model-config="dateTimePickerConfig"
    :popover="{
        visibility: 'click',
        placement:  'auto',
     }"
    :masks="{ inputDateTime: 'MM/DD/YYYY h:mmA'}">
    <template v-slot="{ inputValue, inputEvents }">
        <div class="form-icon ">
            <input-component
                :value="inputValue"
                v-on="inputEvents"
                placeholder="MM-DD-YYYY h:mmA"
            />
            <Icon name="date-time"/>
        </div>
    </template>
</date-picker>

Your assistance in resolving this issue would be greatly appreciated.

Thank you.

Answer №1

If you're looking to limit the selection of specific hours, it can be done with v-calendar using the following attribute:

<v-date-picker v-model="date" :valid-hours="[0,3,4,5,8,16,20]" is24hr />

Take note of the :valid-hours property where you can specify which hours are accessible for selection. Additionally, if you want users to choose minutes in set intervals, you can also utilize the following:

<v-date-picker v-model="date" mode="dateTime" :minute-increment="15" />

The :minute-increment property enables users to pick time in 15-minute intervals (00, 15, 30, 45). Experiment with this feature as needed.

Regrettably, there isn't a direct way to disable specific minutes, such as preventing the selection of 9:15 AM after someone has booked an appointment at that time. Disabling entire hours is possible but not individual minutes like 9:15 while keeping 9:00, 9:30, and 9:45 available. Please share if you find a workaround.

Hopefully, this information proves useful to anyone using v-calendar.

================ UPDATE =================
Keep in mind that the additional properties mentioned were introduced in a specific version of v-calendar. These features were present in my use of v2.4, whereas they may not be available in v2.3 yet.

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

Javascript datatables do not allow for setting a default column sort

I am encountering an issue where I need to sort the results by a specific column on page load. In this case, I want the initial results to be displayed in descending order based on "RecordDate". However, it seems that the server side is blocking any sort ...

"Encountering difficulties while trying to modify the QuillNoSSRWrapper value within a Reactjs

Currently, I am working on a project involving ReactJS and I have opted to use the Next.js framework. As of now, I am focused on implementing the "update module" (blog update) functionality with the editor component called QuillNoSSRWrapper. The issue I ...

Angular-jasmine: conducting tests on a component that utilizes timeout to render the DOM

Within my custom directive, I have implemented the following functionality: link: function (scope, element) { var editor = CKEDITOR.inline(element.find('div[contenteditable]')[0], {} To ensure that the directive is properly linked and that ...

Having difficulty launching a new window within an app built with Electron and Nexjs (Nextron)

Attempting to launch a (Nextjs-generated) page in a new window is causing an error message to appear: Uncaught ReferenceError: global is not defined Here is the full error: react-refresh.js?ts=1665849319975:10 Uncaught ReferenceError: global is not de ...

How to Retrieve Element Property Values from the DOM with JavaScript

I am currently attempting to access the property of an element within my webpage. My main objective is to toggle a float property between left and right when a specific onClick event occurs. However, despite my efforts, I am facing challenges in even acces ...

The mesh's position has become invalid due to the dynamic change in vertices' positions

When attempting to create a mesh using PlaneGeometry, I encountered an issue where after dynamically changing the geometry's vertices, the mesh's position and rotation were no longer correct. Is there a way to update these properties properly to ...

Perform a series of observables from a dynamically generated array

Currently, I am in the midst of a project (Angular2) where I am dynamically creating Observables and storing them in an array. var ObservableArray : Observable<any>[] = []; //populating the Observable array dynamically for (var i = 0; i < this.ma ...

Extract the innerHTML input value of each row in an HTML table

I've encountered an issue with my HTML table that contains static values, except for one cell which has an input field. When I try to convert the row data into JSON, the single input field is causing complications. Without the input field, I can suc ...

Switch Bootstrap Tab

I have successfully implemented a bootstrap tab on my webpage and it is functioning as intended. Now, I am interested in adding an additional feature to the tabs. My question is, is it possible to toggle the content area if the same tab is clicked again? ...

Warning from Vue: Steer clear of directly changing a prop as it will be replaced whenever the parent component undergoes re-rendering

I've been diving into Vue.js, but I'm encountering an issue. Every time I try to click on the "edit age" or "change my name" button, I get the following error message. [Vue warn]: Avoid mutating a prop directly because the value will be overwrit ...

A correct JSON format for presenting information within an AngularJs framework

I am looking to integrate JSON data into my website using AngularJs. Here is the approach I have taken: First, I created a database in phpMyAdmin. Next, I set up a table with two columns - subject and body. Should an id column be included? After work ...

Utilizing the Twitter API variable within ExpressJS while incorporating AngularJS

Using the "twit" Twitter package from GitHub, I am able to call the Twitter API and retrieve data that is logged in the console. However, I am unsure of how to pass this data to AngularJS in order to display the tweets on the front-end. T.get('search ...

When clicking on the file input field in Angular.js, the image name mysteriously disappears

I am currently utilizing ng-file-upload to upload images with Angular.js. The issue I'm encountering is that when a user selects a file for the second time in the same field, the name of the previously chosen image doesn't display. Below is my c ...

How to disable form submission using ENTER key in jQuery when alerts are present?

My form contains a text input field. To prevent the form from being submitted when ENTER key is pressed, I used this code snippet: jQuery("#inputTags").keydown(function(event) { if (event.keyCode == '13') { event.preventDefault() ...

Issue with displaying checkboxes in the dataTable table

I am currently working with dataTables and encountering difficulties displaying checkboxes on my tables. Below is the code that I have: <table id="employeeList" class="table table-sm table-bordered table-hover" cellspacing="0" width="200%"> &l ...

Encountering a Typescript error while attempting to utilize mongoose functions

An example of a User interface is shown below: import {Document} from "mongoose"; export interface IUser extends Document{ email: string; password: string; strategy: string; userId: string; isValidPassword(password: string): ...

The API response indicating success is simply denoted as "Success: True", without any accompanying data

I've set up my application on an express server with a proxy to communicate with the API server. Here's a snippet of my code: HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> ...

Sveltejs template not displaying on M1 MacBook Air after running - stuck on blank screen

Currently, I am in the process of learning Sveltejs and have been utilizing for the tutorial, which has been quite effective. However, I decided to work on developing and testing Sveltejs applications locally on my MacBook Air M1. I downloaded the provid ...

Is it possible to selectively export certain interfaces within a .d.ts file?

// configuration.d.ts export interface Configuration { MENU_STRUCTURE: Node[]; } interface Node { name: string; } Looking at the snippet above, I am aiming to only export Configuration. However, I noticed that I can also import Node from an ext ...

Selection auto-closing feature

I am currently working on a button that generates a dropdown menu with various categories to choose from. I would like the dropdown to automatically close when I click outside of it, similar to how a lightbox or modal popup works on a webpage. Currently, I ...