Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required date picker #44

Open
brabo-dan opened this issue Jan 29, 2018 · 2 comments
Open

Required date picker #44

brabo-dan opened this issue Jan 29, 2018 · 2 comments

Comments

@brabo-dan
Copy link

If I use any common JS date pickers, as Bootstrap datepicker lib, or jQuery UI date picker. And I have required date filed. Then validation error occures in a moment, I select date from the datepicker.

Resulting situation is, I have error state field, but value is set.

obrazek

Form can be posted, so it is not blocking. But it looks bad. And end users are still reporting it as an error.

@f3l1x
Copy link
Member

f3l1x commented May 14, 2018

What do you suggest?

@Kazzaky
Copy link

Kazzaky commented Jun 21, 2021

It's because the datepickers use non-native event change triggerer, so 'change' event will never happend (on the live form validation handler side), only 'blur' which actually adds the error, with the old 'Nette.addEvent' it worked well, but with nowadays 'addEventListener' it doesnt, there are two ways to solve this issue, first is to trigger the native event manually via custom callback like this:

el.datepicker({
    onSelect: function() {
        this.dispatchEvent(new Event('change'));
    }
});

or second way (imo better) is to edit the LiveForm.setupHandlers as the function comment suggest and use jquery event handlers instead native addEventListener.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants