The Pattern Validator Object

Pattern validator ensures that the input text does not validate specified pattern.

var btnSubmit = new TButton('Submit');
var chvPattern = new TPatternValidator(/^([5-9]\d|[1-9]\d{2,})$/);
var layHorizontal = new THorizontalLayout();
var vtbSample = new TValidatableTextBox(300, chvPattern);
var wndCHVSample = createWindow('Pattern Validator Sample');

var onValidate = function() {
      if (vtbSample.isValid()) {
         btnSubmit.enable();
      } else {
         btnSubmit.disable();
      }
};

btnSubmit.disable();
vtbSample.setValue('');
vtbSample.setOnValidationChanged(onValidate);

layHorizontal.add(new TText('Enter a number bigger than 49:'));
layHorizontal.add(vtbSample);

wndCHVSample.add(layHorizontal);
wndCHVSample.add(btnSubmit);
showModal(wndCHVSample);

In the previous example, the submit button will only be enabled if the user type in a number bigger than 49.

Pattern validator constructor takes one parameter:

new TPatternValidator(pattern);

Pattern Validator Methods and Properties
Method/Property Description
getPhrase Gets validator object text message
validate Validates input text against specified pattern. Form:

validate(text)