Manual:DateInputWidget

From Linux Web Expert

Revision as of 12:58, 29 March 2024 by imported>APaskulin (WMF) (Update link)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

File:DateInputWidgetUploadWizard.png
Screenshot of the DateInputWidget as used in the UploadWizard interface

MediaWiki includes a DateInputWidget that can be used for user interfaces that require selecting a date. You can see an example of it in the interface for UploadWizard.

Example code:

// Accessing values in a DateInputWidget
var dateInput = new mw.widgets.DateInputWidget();
var $label = $( '<p>' );
$( 'body' ).append( $label, dateInput.$element );
dateInput.on( 'change', function () {
    // The value will always be a valid date or empty string, malformed input is ignored
    var date = dateInput.getValue();
    $label.text( 'Selected date: ' + ( date || '(none)' ) );
} );

For more information, see the code documentation.

See also