iMask

by Fabio Zendhi Nagao (http://zend.lojcomm.com.br)

iMask is an open source (free) javascript tool for creating input and textarea masking.

important update:

jQuery port of iMask is available at https://github.com/cwolves/jQuery-iMask. Check out the demo.

Prototype.js port of iMask is available at https://github.com/victor-homyakov/pMask.

From now on, the development of iMask is taken by Guillaume at https://sourceforge.net/projects/imask/. MooTools version 1.2 and 1.3 are available there.

index:

  1. Index
  2. Abstract
  3. Examples
  4. Browser compatibility
  5. Features
  6. Usage
  7. License
  8. Download
  9. Version history
  10. Comments

abstract:

Who haven't ever wanted to apply an input mask to an HTML form field? This very common feature in traditional GUI applications is not natively supported by web applications. iMask goal is to implement an easy way for developers to add mask into their form fields, increasing the database and software consistency with standard compliant XHTML and unobtrusive JavaScript.

examples:

browser compatibility:

iMask is compatible and tested in Internet Explorer, Firefox (and its mozilla friends), Opera and Safari (thanks macspyre for testing it). But it should work in other browsers too... If you successfully find another compatible browser, please let me know ;)

features:

1. keyboard control

Special keys functions

2. dynamic fixed mask definition

Create your own masks for type "fixed" using [9, a, x] notation:

9 := numerical symbols.
Default set is: "123456789"

A := alphabetical symbols.
Default set is: "abcdefghijklmnopqrstuvwxyz"

X := alphanumerical symbols.
Default set is both alphabetical and numerical symbols.

3. event handling

Integrate with other components and create rich interactive interfaces. iMask class can be initialized with the following customizable methods:

  • onFocus - fires when field get focus
  • onBlur - fires when field lost focus
  • onValid - fires when user press a valid char
  • onInvalid - fires when user press a invalid char
  • onKeyDown - fires at every key press

4. dynamically charset definition

Want to extend the default charset for a card? [9, a, x]

Initialize iMask with your own set of validNumbers, validAlphas and validAlphaNums!

how to use:

First of all, iMask is built over MooTools v1.1, so both libraries are required.
Get MooTools at http://mootools.net and iMask here.
With scripts in hands, include them between your "head" definition:

Initialize the iMask class:

That's it, at this rate you should be able to use iMask. To enable a mask for a field, just add the properties class="iMask" and alt="<options>".

<options> is a string representing an object in JavaScript Object Notation (aka. JSON). Here is the list of valid properties:

  • type : (string) fixed || number.
  • mask : (string) your mask using [ 9, a, x ] notation.
  • stripMask : (boolean) true || false.

Nothing better than an example to explain a tool usage, so here is the code behind this page examples:

license:

This piece of code is is released under the Open Source MIT license, which permits you to use it and modify it in every circumstance. For more details read it below:

The MIT License

Copyright (c) 2007 Fabio Zendhi Nagao - http://zend.lojcomm.com.br

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

download:

iMask is available in the formats below:

version history:

05/22/2007 : v1.0 - first public release

03/16/2007 : v0.002

03/11/2007 : v0.001

comments:

Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

/common/comments/list.asp, line 17

Did you like it? Disliked it? Express your feelings, leave-me a message. (Yellow fields are required)

© 2007-2009 Fabio Zendhi Nagao (nagaozen) - http://zend.lojcomm.com.br/