Can I set input type time to just select hours, not to select minutes. I just want to select from and to for hours like 2:00 to 3:00 not with any minutes.
Can I set input type time to just select hours, not to select minutes. I just want to select from and to for hours like 2:00 to 3:00 not with any minutes.
you can use an input type="number" and adjust the values with attributes.. Like that:
<input type="number" id="yourId" name="yourName" min="1" max="24">
The user shoulb be able to input only numbers between 1 and 24 hours. To prettify your design you can use some label after the input field showing something like "Hour" to reference the plural.
Use simple select tags as shown below:
<label for="from">From: </label>
<select name="from" id="from">
<option value="1">1:00</option>
<option value="2">2:00</option>
<option value="3">3:00</option>
<option value="4">4:00</option>
<option value="5">5:00</option>
</select>
<label for="to">To: </label>
<select name="to" id="to">
<option value="1">1:00</option>
<option value="2">2:00</option>
<option value="3">3:00</option>
<option value="4">4:00</option>
<option value="5">5:00</option>
</select>
You can use the step attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time
<form>
<input type="time" required step="3600">
<button type="submit">Submit</button>
</form>