Hi Robin,
AFAIK widgets are validated in two cases :
- When getValue is explictly called
- When validate is called

This means that in a normal form usage, they are validated :
- If another component (say, an event listener) calls the getValue() for some reason.
- If a submit button is pressed (explicit call to validate() )
- If an action button with validate = true is pressed (explicit call to validate() )

The "http submit" that happens with submit-on-change="true" or with an event handler, with or without ajax, is not a "cform submit", so doesn't trigger validation if not as a side effect of something else going on.

You could try calling validate() explicitly from inside your event handler, it could work but i've never tested it, so let me know :)

Regards,
Simone

--
Simone Gianni


Robin Wyles wrote:

Hi All,

I have a text field with custom validation and a value-on-changed event listener...

<fd:field id="video_key" required="true">
    <fd:datatype base="string" />
    <fd:validation>
        <fd:javascript>
            return validateVideoKey(widget);
        </fd:javascript>
    </fd:validation>
    <fd:on-value-changed>
        <fd:javascript>
            updateFiles(event.source);
        </fd:javascript>
    </fd:on-value-changed>
</fd:field>

When the value of the field changes, the custom validation is executed and if successful then my value-on-changed listener is executed also - all good. If the validation fails then my value-on- changed listener is not executed, which is (I think) also the expected behaviour.

However, when the validation fails as a result of the value-on- changed listener being fired no validation error message is show on the form. My custom validation sets a ValidationError on the widget, and this gets displayed if the form is submitted with a submit button, just not when submitted as a result of the value-on-changed. This is true with both AJAX enabled or AJAX disabled on my form.

Is there a way I can get the widget to display its ValidationError after being validated as the result of the value-on-changed?

Alternatively, and in my particular case this is preferable, is there a way I can disable the validation before the value-on-changed on this field?

Thanks,

Robin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]