HTML Form with javascript date picker (datetime-local) not responding to required

Viewed 13

Is there a way to have a user be required to select a date from the picker before submitting the form. Of note: the form works when a date is selected. If a date is not selected the form allows the user to hit enter although crashes after. Also of note: if I change the type to date, text, number etc the form required function works, however, the user is then not able to use the javascript date picker.

<form method="POST" action="placeorderfinal.php">
    <label for="Booking date & time">Order for (date & time): </label>
    <input type="datetime-local" id="orderdate" name="orderdate" placeholder="yyyy-mm-dd HH:MM" required/> 
1 Answers

You should use javascript to solve your problem then. When the users clicks submit check the date input if nothing is entered throw an error.

Related