How does to fix node validation error, when it get value from TypedInput Select box?

Hi all,

I create node. And it has validate function for its field.

Validation has using value from 'TypedInput Select box'. They names 'node-input-action' and 'node-input-datetimeMode'. But the problem is from 'node-input-datetimeMode'.

Please see below

datetimeInitialDate: {
    value: "",
    validate: function (v) {
        if ($("#node-input-action").typedInput('value') === ACTION_DATETIMEPICKER) {
            if ($("#node-input-datetimeMode").typedInput('value') === DATETIME_MODE_DATETIME || $("#node-input-datetimeMode").typedInput('value') === DATETIME_MODE_DATE) {
                if (!v.match(/^\s*$/)) {
                    const result = isValidDate(v);
                    return result;
                } else {
                    return true;
                }
            } else {
                return true;
            }
        } else {
            return true;
        }
    }
}

After I run flow on browser, the client error is occured.

Validation error: node-line-bot-quick-reply-item 3f71c1a2ce19ff2a property: datetimeInitialDate value:  Error: cannot call methods on typedInput prior to initialization; attempted to call method 'value'
    at Function.error (vendor.js?v=2.2.2:2:2589)
    at HTMLInputElement.<anonymous> (vendor.js?v=2.2.2:10:5615)
    at Function.each (vendor.js?v=2.2.2:2:2976)
    at s.fn.init.each (vendor.js?v=2.2.2:2:1454)
    at s.fn.init.t.fn.<computed> [as typedInput] (vendor.js?v=2.2.2:10:5357)
    at Object.validate (<anonymous>:316:59)
    at a (red.min.js?v=2.2.2:18:373999)
    at i (red.min.js?v=2.2.2:18:374649)
    at v (red.min.js?v=2.2.2:18:374357)
    at HTMLInputElement.<anonymous> (red.min.js?v=2.2.2:18:375995)

So how does to fix node validati error, when it get value from TyponedInput Select box? :thinking:

Moreover, I guest when I remove only code for reading 'node-input-datetimeMode' value, reading 'node-input-action' value is not error. :thinking:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.