I am trying to put custom validation on HTML5
input control time
. I am able to successfully put the custom validation but it's also making it required even tough required is false for the control.
Here is my code:
<input type="time" value="8:00"
oninvalid="this.setCustomValidity('Enter Valid Time')"
oninput="setCustomValidity('')"/>
I also tried title
attribute but didn't work. Input could be not required.
Update: Following code is working now:
<input type="time" value="8:00"
oninvalid="this.setCustomValidity('Enter Valid Time')"
oninput="this.setCustomValidity(''); return false;"/>
It shows me perfect validation if I put invalid value and click on Submit,but when I clear it and click on submit it is forcing me to have value in the textbox
even tough it is not required.