Get value from DatePicker even if invalid (or nonsense) in Vaadin 23

I have an non-required date picker field. If one types in e.g. a text I want to display an error message. In the validator I get a null value instead of the proper text value.

Is there a way to distinct between empty and invalid values to display an error message accordingly?

Thanks and Best Regards
Matt

There is ticket about it for Vaadin 24: Refining Input Validation Logic · vaadin · Discussion #4434 · GitHub

So, in short, in Vaadin 23 I don’t think the invalid value in the client side is available on the server side.

Mhh ok I already tried with getElement().executeJs(“return document.getElementById(‘my-date-picker-id’).value” but since there is no change event fired it does not work as expected.

That won’t work, the date picker itself doesn’t hold the input value, it’s the internal <input> element you want
image.png

The root element has an element.inputElement getter which you can use to your advantage here

In Vaadin 24 there is chained client side validation for this. I.e. the DatePicker with invalid format will turn red and Binder will be notified, thus recognizing that the form is not valid. This feature is also in the latest Vaadin 23 behind feature flag.

Thanks I found a satisfying (temporary) solution which uses JS , as long as we do not have migrated to Vaadin24. @yummy-rhino I have tried the feature flag as well but it does not give me the proper value an does not display a proper error message.

Yes, currently DatePicker is just red, the localizable error message feature is coming in 24.2