How do I restrict past dates in input type Date? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I restrict past dates in input type Date?

I am trying to restrict past dates in type="date" line 145. I made a function in line 90 till line 110 but I don't know what I did wrong. The user can still choose past dates. https://code.sololearn.com/W5WjL9n4lN7p/?ref=app

11th Jun 2020, 2:45 PM
Fábio Gonçalves
Fábio Gonçalves - avatar
1 Answer
+ 2
<form> <label> Choose your preferred meeting date (required, April 1st to 20th): <input type="date" name="meeting" min="2020-07-04" max="2020-07-18" required> <span class="validity"></span> </label> <p> <button>Submit</button> </p> </form> label { display: flex; align-items: center; } span::after { padding-left: 5px; } input:invalid + span::after { content: '✖'; } input:valid+span::after { content: '✓'; }
11th Jun 2020, 5:16 PM
JaScript
JaScript - avatar