restrict options for type="date" and type="time" fields

Asked

Viewed 796 times

0

I am making a scheduling form. The company is not 24 hours and does not work every day of the week. In this case I need to narrow the options according to the company calendar.
I thought to validate with js, but this will be anti functional, a did that I will allow the selection of the date and only then inform that it is not possible.

I needed some kind of code that displayed only the days available. Examples:
<input type="date">:displays dates from Monday to Friday
<input type="time">:displays hours from 8h to 18

1 answer

1


To allow selecting only the hours from 8 to 18 in the field time, just use the attributes min and max:

Hora <input type="time" min="08:00" max="18:00">

Already with regard to the field of the type date, in that link something like that was done. Natively HTML does not offer any attributes to do this type of limitation, so it would have to be done with jQuery, as shown in the link above.

  • 1

    Man, this is exactly what I needed. Thanks for the help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.