The Validatable Text Box Object

Validatable text box object is based on the TextBox object, but it adds validating behavior using several validators (see Validators section).

var vtbSample = new TValidatableTextBox(300, new TEmptyValidator());
var wndValidatableTextBoxSample = createWindow('Validatable Text Box Sample');

wndValidatableTextBoxSample.add(vtbSample);
showModal(wndValidatableTextBoxSample);

Validatable text box object constructor takes three parameters:

new TValidatableTextBox(width, validator, isPassword);

Where validator is a specific validator object (in this example we use EmptyValidator object).

Sign In Form Example
var m_btnSignIn = new TButton('Sign In');
var m_layData = new TVerticalLayout();
var m_layForm = new TFormLayout();
var m_vldUsername = new TValidatableTextBox(250, new TEmptyValidator());
var m_vldPassword = new TValidatableTextBox(250, new TEmptyValidator(), true);
var m_window = createWindow('Sign In Form');

var onSignInClick = function() {
      // Send Request to the server
};

var validateButton = function() {
      if (m_vldPassword.isValid() && m_vldUsername.isValid()) {
             m_btnSignIn.enable();
      } else {
             m_btnSignIn.disable();
      }
};

m_btnSignIn.disable();
m_btnSignIn.setOnClick(onSignInClick);
m_layForm.setDirection(TLang.getDirection());
m_layData.add(m_layForm);
m_layData.add(new TVerticalDelimiter(5));
m_layData.add(m_btnSignIn);
m_layForm.add(new TText('Username:'), m_vldUsername);
m_layForm.add(new TText('Password:'), m_vldPassword);
m_vldPassword.setMaxLength(20);
m_vldPassword.setOnValidationChanged(validateButton);
m_vldUsername.setMaxLength(20);
m_vldUsername.setOnValidationChanged(validateButton);
m_window.add(m_layData);
showModal(m_window);

Validatable Text Box Methods and Properties
Method/Property Description
disable Disables validatable text box object
enable Enables validatable text box object
getHeight Gets validatable text box object height
getValidator Gets validatable text box object validator
getValue Gets validatable text box object text value
getWidth Gets validatable text box object width
isValid Returns true if the value of the validatable text box is valid and false if not
setDirection Sets validatable text box object direction from left to right (ltr) or from right to left (rtl). ltr is the default value
setFocus Sets focus on the validatable text box object
setMaxLength Sets max length for input characters in the validatable text box object
setOnValidationChanged Sets a callback that will be called when the value is changed. Form:
setOnValidationChanged(callback)
setReadOnly Sets validatable text box object as read only
setValue Sets text value for the validatable text box object
unsetReadOnly Unsets validatable text box object as read only