Maximizing the functionality of a datetime picker with dual validators

I have successfully implemented a Date time picker on my website. Everything is functioning properly, but I am looking to apply two validators: one to disable Saturday and Sunday, and the other to exclude US holidays. Below is the function I am currently using that disables Saturday and Sunday:

rome(mm,{
  dateValidator: function (d) {

   var dates = moment(d).day() !== 0 && moment(d).day() !== 6;
return dates;
 },
min: s,
max: m,
time: false
});

The following code snippet works for excluding holidays:

rome(mm,{
     dateValidator: rome.val.except(['2015-04-20', '2015-04-18', '2015-04-15']),
    min: s,
    max: m,
    time: false
    });

However, I am seeking guidance on how to combine both validators. Can anyone assist me with this challenge?

Answer №1

Give this a shot:

weekDayValidator: function(date) {
    var dayOfWeek = moment(date).day();
    return dayOfWeek != 0 && dayOfWeek != 6 && excludeWeeks(['2015-04-20', '2015-04-18', '2015-04-15'])(date);
}

excludeWeeks() is designed to return a function, so incorporate that into your weekday validation logic.

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

PugJs - unable to locate file / file does not exist

Today marks my initial attempt at delving into pugJs and utilizing the command prompt, yet I encountered an error: Error: ENOENT: no such file or directory, lstat 'C:\Users\aya' Click here to view the screenshot of the error displa ...

Retrieving server information using AJAX in React

I've been attempting to utilize an AJAX call in order to fetch server data for my React Components. However, I'm encountering difficulties when it comes to displaying it with React as I keep receiving this error: Uncaught TypeError: Cannot read ...

Modify a HTML element periodically

My first project involves creating an HTML5 clock, but I'm encountering issues with updating the .innerHTML property every second. Interestingly, console.log is working perfectly fine for me. Here's my main.js: var baseDate = new Date(); var ...

An unexpected error occurred in React.js when trying to use WebRTC RTCPeerConnection.addStream function, indicating

I'm trying to create a basic video chat using react.js and WebRTC. However, I'm encountering an error on line pc.addStream(localStream): TypeError: Argument 1 of RTCPeerConnection.addStream is not an object. Additionally, I can't seem to ...

Eliminate the CSS triggered by a mouse click

Having some difficulty toggling the switch to change the background color. Struggling with removing the applied CSS and getting it to toggle between two different colored backgrounds. Code Sample: <!Doctype html> <html lang="en"> <head> ...

How does jquery's removeClass function on a button continue to function smoothly even after an ajax call

Code Snippet: <span class="input-group-text"> <button type="button" class="btn btn-outline-danger btn-sm owner_button owner_check" name="owner_check" > <i class="far fa-check-circle"></i> </button> </span> ...

Switch Cursor on Movable Area in Electron

Working on a project in Electron and having some trouble with a frameless window. I have designated certain top areas as draggable using -webkit-app-region: drag, but the cursor will not change as expected. Although this code snippet won't make the e ...

Placing a div on top of a link renders the link unusable

I am facing a situation and require assistance (related to HTML/CSS/JS) I currently have a div containing an image (occupying the entire div space) such that when hovered over, another div with an image is displayed on top (the second div is semi-transpar ...

Unable to utilize a variable for accessing an array element within a field

What is the reason I am unable to use a variable to access something inside my document? It seems that hard coding the field works, but when using a variable, it does not yield the expected result. building = "AS" room = "243" item = "whiteBoard.votes[0 ...

Cannot retrieve the <li> element from the array

I am trying to display list items inside an ordered list (ul) from an array, but I am facing issues with it. Whenever I try to map through the array, I encounter an error message saying Map is not a function. Any assistance on resolving this would be hig ...

"Encountering an error: invalid CSRF token in Node.js csurf

I have been utilizing the npm module csurf to generate a token. Initially, I retrieve the token from the server and then utilize it for the /register request. When I replicate these steps in Postman, everything seems to function correctly, but unfortunatel ...

Import reactjs modules without the need for Browserify, Webpack, or Babel

I am attempting to set up a TypeScript HTML application in Visual Studio. My goal is to incorporate reactjs v0.14.7 without relying on tools like Browserify. But, how can I utilize the react-dom module in this scenario? Let's set aside TypeScript fo ...

Retrieve the text content of a datalist option by accessing the label with jQuery

Utilizing data from a Json, I am populating a data-list in html. The options are added to the data-list with both value and label text. Upon clicking an option, I aim to insert both the value and text into a form text field. While accessing the option&apo ...

I'm curious about the potential vulnerabilities that could arise from using a Secret key as configuration in an express-session

Our code involves passing an object with a secret key's value directly in the following manner --> app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: true, cookie: { secure: true } }) I am pondering wheth ...

Executing two functions during a single request

Let me give you a quick rundown of what I am aiming to achieve: Essentially, on the user interface side, a user can update their account information using a form. This form then gets sent to the same HTTP request no matter how many fields are modified. T ...

Updating variable value in a Javascript function

I'm currently working on a signup page and I need to verify if an email address already exists in the database. var emailnum = getEmailCount(`select * from contactinfo where email='${email}'`); console.log(emailnum); // Output shows ...

Deconstructing arrays in the req.body object in a Node.js Express application

Received an array in the request body as follows: [ { "month" : "JUL", "year" :"2018" }, { "month" : "JAN", "year" :"2018" }, { "month" : "MAR", "year" :"2018" } ] This array consists of two parameters (month:enum and year:string). ...

Retrieving CSV files from an Express backend for use in an AngularJS application

I came across a similar question on Stack Overflow, but unfortunately the solution provided did not work for me. When I tried using the code snippet mentioned: $('<form action="'+ url +'" method="'+ ('post') +'">&a ...

Enhancing functionality in Javascript by employing prototype descriptor for adding methods

Code: Sorter.prototype.init_bubblesort = function(){ console.log(this.rect_array); this.end = this.rect_array.length; this.bubblesort(); } Sorter.prototype.init = function(array,sort_type){ this.rect_array = array; this.init_bubblesort(); } Wh ...

The filter method in combination with slice array functions is not functioning properly

My search input is used to filter an array of users displayed in a table. The table has pagination set up so that only 10 users are shown per page. Oddly enough, the search filter only seems to work on the first page. Once I navigate to another page, the ...