Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

renaldy's avatar

Start date, end date

So, here, I have 2 inputs, input 1 (start date), input 2 (end date), now I want the input to have max and min, input 1 min (17-10-2018), and input 2 max (21- 10-2018) ... now I want if input 1 is less than 17, then it will display an alert containing ("input must not be less than 17"). and if input 2 is more than 22, then it will display an alert ("the input cannot be more than 21"). Please help me ....

0 likes
3 replies
tykus's avatar

You can set min and max attributes on a datepicker input, which will prevent out-of-range selections (on supported browsers):

<input type="date" id="start" name="trip" min="2018-10-17" max="2018-10-18" />

On the server-side, you can use the after:date/after_or_equal:date and before:date/before_or_equal:date validation rules.

Please or to participate in this conversation.