Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict user input of 24 format time into input field?

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.

like image 654
iyel Avatar asked Aug 03 '12 22:08

iyel


People also ask

How do I change input type time in 24-hour format?

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".

How do you limit input time?

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.

How do I restrict an input type number?

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.”


1 Answers

Like that ?

$(document).ready(function(){
  $("#time").inputmask("h:s",{ "placeholder": "hh/mm" });
});​
like image 120
Julien Ch. Avatar answered Sep 22 '22 23:09

Julien Ch.