Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Drupal 8 Date widget help text for browsers that dont support html5 date input.
// HTML5 date elements use the user's browser date format,
// but browsers that don't support it have a more confusing interface
// requiring help text.
Drupal.behaviors.DateHelp = {
attach: function (context, settings) {
if ( === false) {
// If there is no help text div, first add one.
$('div.field--widget-datetime-default:not(:has(.description))').each(function() {
$(this).find('input').after('<div class="description"></div>');
$('.field--widget-datetime-default .description').append(' Enter dates as yyyy-mm-dd.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment