The Change Validator Object

Change validator is basically used with Validatable Text Box object. The main purpose of this object is to validate original set text against any other input text to check if they differ or not.

var btnSubmit = new TButton('Save New Title');
var chvTitle = new TChangeValidator(new TEmptyValidator());
var layHorizontal = new THorizontalLayout();
var vtbTitle = new TValidatableTextBox(300, chvTitle);
var wndCHVSample = createWindow('Change Validator Sample');

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

btnSubmit.disable();
chvTitle.setOriginalValue('Some Title');
vtbTitle.setValue('Some Title');
vtbTitle.setOnValidationChanged(onValidate);

layHorizontal.add(new TText('Change Title:'));
layHorizontal.add(vtbTitle);

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

When the user changes the text inside text box, the save button is enabled.


Change validator constructor takes one optional parameter:

new TChangeValidator(parentValidator);

Where parentValidator may be any other validator object. In our example, we used Empty Validator object to reject empty value ''.

Change Validator Methods and Properties
Method/Property Description
getPhrase Gets validator object text message
setCallback Sets a callback that will be called after validation process. Form:

setCallback(callback)
setOriginalValue Sets an original value that the validator will use to compare it against input text. Form:

setOriginalValue(value)
validate Validates an input text value against the original set value. Form:

validate(inputValue)