Reputation: 803
In my application the Time will always be like HH/00/00. So users will only need to enter the hour value as the minutes will be 00. I could not find a way to change the format of the input=time to only HH.
I found some articles about assigning step value but it doesn't work.
Any idea about preventing users to select minutes and force him to only select hours?
<div class="md-form mx-5 my-5">
</div>
<label>Choose your time</label>
<input type="time" /
Upvotes: 1
Views: 4465
Reputation: 307
How about some JS code ? a simple one really, like the one below, you can add more conditions to make it much more strict, but here you go:
const timeInput = document.getElementById('time');
timeInput.addEventListener('input', (e) => {
let hour = e.target.value.split(':')[0]
e.target.value = `${hour}:00`
})
<div class="md-form mx-5 my-5">
</div>
<label>Choose your time</label>
<input id="time" type="time">
Upvotes: 3