I am trying to add a max date to my HTML5 input element. It works great in chrome, and it works sort of Firefox. In Firefox I have set the max and I can't choose a date past it when using the GUI for date selector. But if I type a date it can still get past the max limit. is there a way to fix it?
<input class="form-control me-md-5" type="date" max="2999-12-31" name="noteDate" id="noteDate" />
CodePudding user response:
You can type in a value greater than the max, but when you try to submit the form containing that input, you will get an error message.
As far as I can see, the behaviour in Firefox 92 is no different to the behaviour in Chrome 94, which also lets you type in a date after the maximum, and doesn't display an error until you submit the form.
If you want more feedback, you can use the :invalid
pseudo-class to apply styles to the control when the value is not valid.