I have an input field with time in HH:MM. And I need to manage that users can only enter correct time, to prevent them from entering wrong time.
A time in 24-Hour Format Regular Expression Pattern is
([01]?[0-9]|2[0-3]):[0-5][0-9]
And I've found mask input plugin https://github.com/RobinHerbots/jquery.inputmask
But I dont know how to do what I want. Thx a lot.
How do I display the time in 24-hour format in HTML? input type="time" The value of the time input type is commonly in 24-hour format ("hh:mm"). If the time includes seconds the format is always "hh:mm:ss".
To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. The max and min attributes are used with number, range, date, datetime, datetime-local, month, time and week input types.
Complete HTML/CSS Course 2022 To limit an HTML input box to accept numeric input, use the <input type="number">. With this, you will get a numeric input field. After limiting the input box to number, if a user enters text and press submit button, then the following can be seen “Please enter a number.”
Like that ?
$(document).ready(function(){
$("#time").inputmask("h:s",{ "placeholder": "hh/mm" });
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With