HTML5 input type date disable dates before today -


is there way disable dates before today in html5 <input type="date"> ? tryed with: <input type="date" min="<?php echo $today; ?>"> works on desktop browsers...safari mobile still allow scrolling dates before.

input date must in iso format (which supported mobile browsers).

there no possible way pure html5.

but javascript, can like:

<input name="settodaysdate" type="date"> 

and;

var today = new date().toisostring().split('t')[0]; document.getelementsbyname("settodaysdate")[0].setattribute('min', today); 

this little script change min today's date in iso format.

live example here: jsfiddle


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -