mask([mask], [placeholder])

Class: TextField.

Description:

Sets or gets a text mask formatter with a specified mask string and a placeholder character.

A mask string defines the allowed characters at each position.
Each special character in the mask has a meaning:

Example masks:

Parameters:

Name Type Default Description

[mask]

string

Text mask string. Set to empty string or null to clear the mask.

[placeholder]

string

"_"

A character to use for empty characters in the mask. Default is "_" character.

Returns:

When setting a mask, returns this TextField component for chaining. When called without arguments, returns the current mask information object.

Type: Object | TextField

Examples:

// U.S. Phone number mask
textfield.mask("(###) ###-####", "_");
// Date input (MM/DD/YYYY)
textfield.mask("##/##/####", "_");
// Time input (HH:MM)
textfield.mask("##:##", "_");
// Product code input
textfield.mask("AAAA-####", "_");
// Get current mask settings
const info = textfield.mask();
console.log(info.mask, info.placeholder);