A jQuery plugin to make field masks.
Pull request Compare This branch is 682 commits behind igorescobar:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
jquery.mask.js
jquery.mask.min.js

README

Live Demostration & Usage Examples
http://igorescobar.github.com/jQuery-Mask-Plugin/

Features
  - String/Numeric/Alpha/Mixed masks.
  - Reverse Mask.
  - Data type validation.
  - Automatic maxlength.
  - Live event's for ajax/realtime apps.
  - Callbacks.
  - On-the-fly mask change.

BASIC EXAMPLES
$(document).ready(function(){
  $('.date').mask('11/11/1111');
  $('.time').mask('00:00:00');
  $('.date_time').mask('99/99/9999 00:00:00');
  $('.cep').mask('99999-999');
  $('.phone').mask('9999-9999');
  $('.phone_with_ddd').mask('(99) 9999-9999');
  $('.phone_us').mask('(999) 999-9999');
  $('.mixed').mask('AAA 000-S0S');
});
  
CALLBACK EXAMPLES
  var options =  { onComplete: function(cep) {
                    alert('Mask is done!:' + cep);
                  },
                  onKeyPress: function(cep, event, keyCode){
                    alert('An key was pressed!:' + cep + ' event: ' + event + ' keyCode: ' + keyCode);
                  }};

  $('.cep_with_callback'.mask('00000-000', options);
  
ON-THE-FLY MASK CHANGE
  var options =  {onKeyPress: function(cep){
                    var masks = ['00000-000', '0-00-00-00'];
                      mask = (cep.length>7) ? masks[1] : masks[0];
                    $('.crazy_cep').mask(mask, this);
                  }};

  $('.crazy_cep', '00000-000', options);
  
MASK LEGEND
- 0,1,3,4,5,6,7,8 or 9: Only Numbers
- A: Numbers and Letters
- S: Only A-Z and a-z characters