dhtmlxForm validation within an object

Hi, I’d love to be able to pass dhtmlxForm validation within an object.

ie:

validate: “this.myValidationRoutine”
or
validate: “(myValidationRoutine).bind(this)”

Is there a way to call the validate routines with context?

Thanks in advance.

Hi

What object is ‘this’ point to? Can you provide more code?

A custom object of my own.

Basically I wrote an object that holds a tab, a toolbar, a grid and a form in it.

Then I can instantiate multiple copies of myObject.

In this example, I wanted to have a validation within the form on myObject, but was unable to because of the validation rule execution syntax. Example: I wanted to validate against another form object on the same page (ie: val2 must be greater than val1). I cant use this.myForm.getItemValue(val1), because ‘this’ has not context within the validator.

The way I worked around it was checking current selected tab and setting myObject to its proper object, then getting myObject.myForm.getItemValue(val1) but using ‘this’ would have been easier.

well,
not so good but works

var yourObject = { validate: function(value, name) { console.log(this, arguments); return true; }, val: function() { var t = this; return function() { return t.validate.apply(t, arguments); } } }; var formData = [ {type: "input", ..., validate: yourObject.val()}, ];