Maskerade jQuery Plug-in


The Maskerade jQuery plug-in allows for validating dates/times, enforcing masks, automatically interprets keyboard entries based on mask settings, and tries to incorporate all of the best functionality of other date/time plug-ins.


In order to use the Maskerade plug-in, you need the following:

  • jQuery v1.6.3 (or higher)
  • jquery.maskerade.js Plug-in

Optional Plugins

To support browsers that don't support the "placeholder" attribute, you can use a placeholder shim, such as


  • Keypress validation (ie. you don't need to submit the form for the mask to be applied)
  • Full keyboard support, including number to text-date interpretation (eg. typing 6 for a month will show June) and number-entry interpretation (eg. typing 02 in a yyyy date field will be interpreted as 2002)
  • Full mouse support
  • Masks can be defined as attributes of the input field; individual jQuery mask calls are not needed
  • Includes time-mask capability, with a date or alone
  • Default values and masks set as placeholders in the input field
  • Ability to set min and max dates allowed on a field
  • Allows for enforcing relational validation (ie. date1 must be before date2)
  • Automatic adjusting for invalid dates (eg. Feb 29, 2001 is adjusted to Feb 28, 2001)
  • Each date/time part fully highlighted on focus
  • Automatic tabbing to next date/time part once interpreted (eg. typing 2 in a "mm" date part will automatically tab you to the next date part), which allows quick keyboard entry
  • Allows for dask masks by quarters (eg. Q1, Q2, etc.)
  • Ability to support multiple languages
  • Custom event handlers; for example, a single keystroke can be defined to change the date to the current date
  • Detach/attach Maskerade behavior from the element


To attach Maskerade to your form elements, just invoke the jQuery plug-in using the following syntax:


You can use any selector that will target date input elements on your page.



This argument is optional and allows you to customize the settings used for each instance of the plug-in. For a list of all available options, see the Options section.

Now that we have a reference to the widget, we can invoke any of the public API calls.

Public API

$("#id").maskerade("val" [, value])

Use the val() method to get/set the value of your input element. The value argument is an optional: if not include, val() returns the value of the field; if it's included, it sets the value of the field to value.

$("#id").maskerade("destroy" [, callback()])

Destroys the Maskerade widget. This restores the original input element in the DOM. A callback can be optionally included.


Boolean of whether or not the field has focus on it or not.


Boolean whether or not the field has been changed from it's original value when Maskerade was attached to the field.


Returns the original value when Maskerade was attached to the field.


There are a number of options available for customizing handling of the widget.

     mask:                      // The date mask; this can be defined as a "data-mask"
                                //   parameter on the input element (see Example
                                //   below)
   , lang: "en"                 // The i18n language to display the dates in;
                                //   languages other than english need to be defined
                                //   to the plugin (see Example below)
   , keyBufferDelay: 1250       // Delay to reset the keyboard buffer after mask input

   // event handlers
   , init: null                 // Callback that occurs when initialization starts
   , ready: null                // Callback that occurs once the plug-in is ready for
                                //   use
   , changed: null              // Callback that occurs once the field has changed
   , completed: null            // Callback that occurs when a value has been
                                //   successfully completed
   , corrected: null            // Callback that occurs when a field has been
                                //   automatically corrected (eg. Feb 29, 2001 being
                                //   corrected to Feb 28, 2001)
   , invalid: null              // Callback that occurs when there is an invalid
                                //   keyboard entry
   , keydown: null              // Callback that occurs when the keyboard key is
                                //   pressed down
   , keyup: null                // Callback that occurs when the keyboard key is
                                //   released
   , keypress: null             // Callback that occurs when the keyboard key has
                                //   been pressed down and released
   , formatMask: null           // Callback used to format the mask for display to
                                //   the user (can be a string "toLowerCase" or
                                //   "toUpperCase" to convert display case of the mask)



Go to next mask position (or next field)

⇧ + TAB

Go to previous mask position (or previous field)

Go to next mask position

Go to previous mask position

Increase the current mask value

Decrease the current mask value


Reset current changes


Deletes current mask value (or entire mask if selected)


Same as [DEL] key.


Go to first mask position


Go to last mask position

NOTE: Standard keyboard operations such as "Select All", "Copy" and "Paste" should all work.

Mask Definitions


1 or 2 digit numeric day of the month (1-31)


2 digit numeric day of the month (01-31)


1 or 2 digit numeric month (1-12)


2 digit numeric month (01-12)


Abbreviated name of month


Full name of month


Start of quarter (Q1, Q2, Q3, Q4)


Start of quarter w/date (Q1 - Jan 1, Q2 - Apr 1, Q3 - Jul 1, Q4 - Oct 1)


Start of quarter w/full date (Q1 - January 1, Q2 - April 1, Q3 - July 1, Q4 - October 1)


End of quarter (Q1, Q2, Q3, Q4)


End of quarter w/date (Q1 - Mar 31, Q2 - Jun 30, Q3 - Sep 31, Q4 - Dec 31)


End of quarter w/full date (Q1 - March 31, Q2 - June 30, Q3 - September 31, Q4 - December 31)


2 digit numeric year (00-99)


4 digit numeric year


1 or 2 digit numeric 12 hour clock (1-12)


2 digit numeric 12 hour clock (01-12)


1 or 2 digit numeric 24 hour clock (1-24)


2 digit numeric 24 hour clock (01-24)


1 or 2 digit numeric minute (0-59)


2 digit numeric minute (00-59)


1 or 2 digit numeric seconds (0-59)


2 digit numeric seconds (00-59)


First character of am/pm



Getting Started

The first thing we need to do is to load the required JavaScript libraries and the CSS stylesheet used by the widget:

<!---// load jQuery and the jQuery iButton Plug-in //--->
<script type="text/javascript" src="//"></script>
<script type="text/javascript" src="./lib/jquery.maskerade.js"></script>
<script type="text/javascript" src="./lib/jquery.html5-placeholder-shim.js"></script>

<!---// load the Maskerade CSS stylesheet //--->
<link type="text/css" href="./css/jquery.maskerade.css" rel="stylesheet" media="all" /> 

Before you can invoke an instance of the Maskerade widget, you must have one or more input elements on your page.

<input type="text" class="input-date" data-mask="mmm dd, yyyy" />

The next step is to actually create an instance of the Maskerade widget. You want to make sure to initialize the widget after all the necessary DOM elements are available, which makes the document.ready event a great place to initialize the widget.

<script type="text/javascript">
$(document).ready(function (){

Now let us take a look at what the code above produced.


You can use all various forms of keyboard input to manipulate the date.

Language Definition Example

Here is how to define a language:

$.maskerade.i18n["fr"] = {
  date: {
      defaultMask: "d mmm yyyy"
    , monthNames: ["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"]
    , monthNamesShort: ["Jan","Fév","Mar","Avr","Mai","Jun","Jul","Aoû","Sep","Oct","Nov","Déc"]

// on DOM ready
jQuery(function ($){
  $(".input-date").maskerade({lang: "fr"});


For many more examples, see the Giva Labs - Maskerade Example Page page.


Copyright 2017 Giva (

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.


v1.0.02 (2017-10-25)
  • Fixed issue in IE11 where an error was thrown when clicking in a date part
v1.0.01 (2012-02-03)
  • Initial release


The following download includes both uncompressed and minified versions of the plug-in and all the CSS and image files required to get you started. See the gettingstarted.htm file for usage instructions and a working example. (35 KB)