The time input is invalid if partially filled. If you leave the input empty, and click the button, you'll get an empty value. If you'll half fill the input, and click the button, the input would be marked as invalid.
Run the code here: https://codepen.io/vinitk/pen/ExxovWL
const element = document.querySelector('button');
element.addEventListener('click', function() {
const input = document.querySelector('input');
const validity = input.checkValidity();
console.log(validity ? input.value : 'partial');
});
.time:invalid {
border: 1px solid red;
}
<input type="time" class="time">
<button>show value</button>
Comments
Post a Comment