I am trying to get my Forms Date Input to only allow Thursday, Friday, and Saturday to be selected. But I can't seem to find a way to do it.
Is there some JavaScript or HTML code I could use to solve this issue?
Here is my current code
import React from 'react';
const CustomForm = () => {
const addTwoWeeks = function () {
let today = new Date();
today.setDate(today.getDate() + 14);
let dd = today.getDate();
let mm = today.getMonth() + 1;
let yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd
}
if (mm < 10) {
mm = '0' + mm
}
today = yyyy + '-' + mm + '-' + dd;
return today;
}
return (
<form>
<label htmlFor="date">Pick-Up Date:</label>
<input type="date" id="date" name="date" min={addTwoWeeks()} required />
</form>
)
}
export default CustomForm;
from How do I get my HTML form date input to only allow specific days of the week to be chosen using JavaScript, React and HTML?
No comments:
Post a Comment