0

How can we enable time control to allow only time? When I enter 00:15 it automatically converts to 00 to 12. Can we achieve this by any way to allow time only? Or can we use this as input type="text" and restrict to accept time format only?

<input type="time" id="appt" min="0" name="appt">

I am referring to this example. https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_time

Oxygen
  • 831
  • 4
  • 17
  • 42
  • Does this answer your question? [Input = time, How to allow input of only the hour. No minutes or seconds](https://stackoverflow.com/questions/58063185/input-time-how-to-allow-input-of-only-the-hour-no-minutes-or-seconds) – kmoser Apr 03 '22 at 03:39
  • In this example its happening same. i.e. If I tried to enter 00 in hours it automatically converts it into 12 – Oxygen Apr 03 '22 at 03:43
  • I have achieved this by using type="text" and validating time format on lost focus of the text. – Oxygen Apr 05 '22 at 02:38
  • If its just minutes, why not go with a select menu? Users can still type in to autoselect - but it would solve the issue, no? – Kinglish Apr 24 '22 at 19:21

1 Answers1

1

When you type 00:15 in the time input, and it converts it 12:15, it actually is correct. Because if you want to set time to 00:15, there is no 00 in a clock, zero start with twelve in a clock.

Now, I don't know in which context you want to use that, but if you only want seconds or minutes. Maybe you can use an number input. <input type="number" placeholder="minutes">

Hope this helps!

Ejaj Ahmad
  • 80
  • 6
  • I understand. But ex if you are having a value as 05:30 and want to make it as 30 minutes only then we must be replace 05 to 00 correct? In this case as soon as you replace 05 to 00 it will become 12. So how can you make 05:30 to 30 minutes? – Oxygen Apr 03 '22 at 03:51
  • The time format issue is explained here: https://stackoverflow.com/questions/13523060/how-to-change-the-time-format-12-24-hours-of-an-input – kmoser Apr 03 '22 at 03:53