javascript - blocking a set of dates in a date input, is it possible?

I'm doing an upgrade to a customer's website and I found the following challenge:

This customer has a reservation system composed of two date input tags to determine the dates he/she is entering a hotel room. I know there's some jQuery and even pure javascript-driven plug-ins (like the DHTMLX suite or even the jQuery EasyUI controls) which do wonders in this sense, but I would like to know if it could be possible to add date blocking functionality into a plain <input type="date"> tag.

So far, I've got to add predefined dates using a <datalist> tag and using it with the date input with the list attribute, but that's about it.

Is it possible to block dates with javascript?



It looks like support for <input type="date"> is still not solid. I was interested to learn that this feature is coming, though. I found this article quite helpful, and its examples use Opera for its examples, which gives you a sense of what is coming.

Here is a fiddle containing a data input. For me it renders as a plain text field :(

<input id="startdate" name="startdate" min="2012-01-01" max="2013-01-01" type="date">

If the HTML5 version doesn't work for you (it didn't for me), you can always use jQueryUI's Datepicker:

<input type="text" id="example-date">

And then in your script:

$('#example-date').datepicker({ minDate: +1 });

This sets the minimum selectable date to a day from the current day.

<input type="date"> 

should support attributes min, max, and value


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.