Created
May 4, 2017 14:28
-
-
Save jodyHamilton/15009b5314c5ff3482e3964d03bba0df to your computer and use it in GitHub Desktop.
Drupal 8 Date widget help text for browsers that dont support html5 date input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 (Modernizr.inputtypes.date === 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