Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 README.markdown
Octocat-spinner-32 mask.coffee
Octocat-spinner-32 mask.js
README.markdown

What?

This "Class" will help you make maskfields in your textFields of Titanium. For example: The postcode 99999999, will be 99999-999.

How?

It's very easy... You just have to use this function, in the "change" textField event.

Example:

Ti.include("mask.js");

var textfield = Ti.UI.createTextField({
    hintText: "Postcode",
    left: 5,
    right: 5,
    top: 150,
    bottom: 150
});

textfield.addEventListener("change", function() {
    Mask.mask(textfield, Mask.postcode);
});

Do you need a generic mask in your field?

You will need to send three parameters in the function: regex (required), syntax (required) and maxValue (optional). See the example:

textFieldPostcode.addEventListener("change", function(evt) {
    Mask.mask(textFieldPostcode, Mask.generic, {
        regex: /^(\d{5})(\d)/,
        syntax: "$1-$2",
        maxValue: 9
    });
});
Something went wrong with that request. Please try again.