1

Is there a way to disable future time input using

<input type='time'>

I want the time to be restricted from 9 am to 3 pm.

ventiseis
  • 3,029
  • 11
  • 32
  • 49

1 Answers1

1

Use min, max and pattern attributes:

<form action="/action_page.php">
  Select a time:
  <input type="time" name="usr_time" min="09:00" max="15:00" pattern="(09|1[0-5]):[0-5]\d">
  <input type="submit">
</form>
Tomasz Jakub Rup
  • 10,502
  • 7
  • 48
  • 49
  • 1
    Yes. but when I specify 9 am to 6 pm . I am able to select 7 pm . Is there a way using javascript or jquery .. I can achieve the same. – Farhee Aslam Mar 14 '17 at 04:18
  • this will only work if input type time is supported by your browsers. you can check here http://www.html5accessibility.com/ – Rashid Mar 14 '17 at 09:15
  • Thank you for the response, it supports my browser. It works fine if min and max is either fore noon or afternoon. But if i try to add min as forenoon and max as afternoon, it does not work as expected. – Farhee Aslam Mar 14 '17 at 10:47