I was pleasantly surprised to discover that the following code, when viewed in Chrome, renders a datepicker:
Older question, but here is the solution I recently had to use.
You will not be able to use the HTML5 date field, but this can be done with jQuery UI datepicker. http://jsfiddle.net/egeis/3ow88r6u/
var $datePicker = $(".datepicker");
// We don't want the val method to include placehoder value, so removing it here.
var $valFn = $.fn.val;
$.fn.extend({
val: function() {
var valCatch = $valFn.apply(this, arguments);
var placeholder = $(this).attr("placeholder");
// To check this val is called to set value and the val is for datePicker element
if (!arguments.length && this.hasClass('hasDatepicker')) {
if (valCatch.indexOf(placeholder) != -1) {
return valCatch.replace(placeholder, "");
}
}
return valCatch;
}
});
// Insert placeholder as prefix in the value, when user makes a change.
$datePicker.datepicker({
onSelect: function(arg) {
$(this).val($(this).attr("placeholder") + arg);
}
});
// Display value of datepicker
$("#Button1").click(function() {
alert('call val(): {' + $datePicker.val() + '}');
});
// Submit
$('form').on('submit', function() {
$datePicker.val($datePicker.val());
alert('value on submit: {' + $datePicker[0].value + '}');
return false;
});
.ui-datepicker { width:210px !important; }