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

[Bug] Checkbox validation does not work (verified in demo app) #89

Closed
lonix1 opened this issue Dec 28, 2023 · 2 comments · Fixed by #91
Closed

[Bug] Checkbox validation does not work (verified in demo app) #89

lonix1 opened this issue Dec 28, 2023 · 2 comments · Fixed by #91

Comments

@lonix1
Copy link
Contributor

lonix1 commented Dec 28, 2023

My model has a bool bound to a checkbox. It's not required, so I should be able to submit the form without checking it. But validation fails for the checkbox and I can't submit.

I tried the demo, and it also fails.

The demo has this:

    [BindProperty]
    public InputModel Input { get; set; } = new();

    // ...

    public class InputModel
    {
        [Remote("CheckboxRemote", "Validations", HttpMethod = "Post")]
        public bool IsChecked { get; set; }
    }

When trying to submit the form on the http://localhost:5000/Demos/Checkboxes page:

NET renders a checkbox and a hidden input ... it is unchecked. Unchecking it should not fail validation.

'IsChecked' is invalid. This is not checked

One can easily verify this repro, just run the demo, go to that page and click submit.

I think it's a bug.

@lonix1 lonix1 changed the title [Bug] Does not respect non-required bool / checkbox [Bug] Checkbox validation does not work Dec 28, 2023
@lonix1 lonix1 changed the title [Bug] Checkbox validation does not work [Bug] Checkbox validation does not work (verified in demo app) Dec 28, 2023
@dahlbyk
Copy link
Collaborator

dahlbyk commented Dec 29, 2023

The demo in question was added in #51 with a proposed fix for #48, but it was changed to include remote validation as of #83. I'm pretty sure "Unchecking it should not fail validation." is no longer true.

  1. If you remove the [Remote] does it work as expected?
  2. If so, could you split that demo into two (client-only and remote)?

@lonix1
Copy link
Contributor Author

lonix1 commented Jan 1, 2024

Done: #91

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

Successfully merging a pull request may close this issue.

2 participants