8000 Figure out how best to handle browser differences · Issue #11 · dominicbarnes/deku-forms · GitHub
[go: up one dir, main page]

Skip to content

Figure out how best to handle browser differences #11

Open

Description

@dominicbarnes

For example, only Chrome actually supports the minlength attribute/validation. There are a few things to consider:

My initial thought is that this library intentionally is a thin wrapper around HTML5 validation, and the best-practice is to always fall back on proper server-side validation should client-side validation fail for any reason. (because you can never trust the client anyways)

However, the goal of this library is to make working with forms easier, and it is nice to have a consistent experience in all browsers. If I were to scrap the reliance on HTML5 validation, we'd need to wire up lots of event handlers under the hood to handle validation in JS-land, which I think is a non-trivial amount of complexity and scope.

One option that I haven't researched very much yet is pulling in some other polyfill library to handle ironing out these differences. So far, I haven't found any that polyfill minlength specifically, so this may not address the core issue.

Another option is to use feature-detection and wire up workarounds where it makes sense. For example, minlength detection fails, so add an onInput that checks the value length and uses setCustomValidity() to communicate the failure. I'm sure there are plenty of caveats to work through with that approach, particularly to make sure that other validation attributes aren't clobbered in the process. (not to mention handling that drift when rendering the validation messages)

Anyways, there's a lot to consider because I want to keep this library clean and maintainable moving forward, while still being useful and relevant.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0