Skip to main content

TextField

Displays a single-line text field for string input.

KeyTypeDescriptionRequiredDefaultMin Version
alignmentstringText alignmentLeft
keyboardstringKeyboard typeDefault
placeholderstringPlaceholder textLocalizable""
isSecurebooleanMask characters with dotsfalse
clearButtonModestringShow clear buttonNever
maxLengthintegerMax text lengthINT_MAX
validationRegexstringRegex used to validate inputnil1.2-10
promptstringPrompt titleLocalizablenil1.2-10
messagestringPrompt messageLocalizablenil1.2-10
okTitlestringPrompt confirm button titleLocalizable"OK"1.2-10
cancelTitlestringPrompt cancel button titleLocalizable"Cancel"1.2-10

This component does not support icon. If label is set, it is recommended to set alignment to "Right".

If the input fails to match validationRegex, it cannot be saved.

If either prompt or message is non-empty, tapping the TextField will show a prompt dialog requesting input there. Requires XXT v1.2-10+ and iOS 8.0+.

alignmentDescription
LeftLeft
CenterCenter
RightRight
NaturalNatural
JustifiedJustified
keyboardDescription
DefaultSystem and third-party keyboards
AlphabetASCII
ASCIICapableASCII
NumbersAndPunctuationNumbers and punctuation
URLURL
NumberPadNumber pad
PhonePadPhone pad
NamePhonePadName and phone
EmailAddressEmail address
DecimalPadNumber with decimal point
clearButtonModeDescription
NeverNever
AlwaysAlways
WhileEditingWhile editing
UnlessEditingUnless editing
Return TypeDescription
stringText field value

Theme

Theme KeyTypeDescription
textColorColorText color
caretColorColorCaret color
placeholderColorColorPlaceholder color

Example

{
default = "";
label = "Username";
cell = "TextField";
key = "username";
keyboard = "Default";
alignment = "Right";
placeholder = "Enter username";
maxLength = 21;
validationRegex = "^[0-9a-zA-Z]+$";
};
{
isSecure = true;
default = "";
label = "Password";
cell = "TextField";
key = "password";
keyboard = "NumberPad";
alignment = "Right";
placeholder = "Enter password";
prompt = "Enter password";
message = "Please input a 6-digit numeric password";
validationRegex = "^[0-9]{6}$";
okTitle = "Save";
cancelTitle = "Cancel";
};

XUI-TextField.png

XUI-TextField-Prompt.png