Giter VIP home page Giter VIP logo

Comments (7)

cferdinandi avatar cferdinandi commented on May 26, 2024

I understand that emails of the form a@b are perfectly valid in the spec

I know that the spec allows emails like that, but outside of internal email addresses at companies, that's not what real email addresses look like. You're correct in your guess that Bouncer uses a different pattern to detect valid emails. It specifically looks for a TLD.

You're certainly welcome to pass in a custom pattern for emails, though, if you want something less restrictive.

It's unclear what "submit button not disabled" in the title means relative to this issue, though. Can you clarify?

from bouncer.

danb-cws avatar danb-cws commented on May 26, 2024

"submit not disabled" just means the standard disabled button as you would style with form:invalid input[type="submit"]
In the code/screenshot as above 'disabled' is styled grey, 'active' is orange.
Thats the only extent of the bug, 'invalid' is somehow not being applied to the form (but you still cant submit... ie its just a visual bug)

from bouncer.

danb-cws avatar danb-cws commented on May 26, 2024

I did try to pass in some alternate patterns with the same result (there seems to be quite a range of different regexes)
Are you able to post a pattern that would be the equivalent of whats used internally?

from bouncer.

cferdinandi avatar cferdinandi commented on May 26, 2024

Ah yes, bouncer doesn't disable any of the buttons on error, though that's certainly something you could extend using the event hooks.

Adding a class to the form is not a bad idea, though. I like that. Will open a new ticket for that as well.

Here's the regex pattern used natively by browsers, per this website:

/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

from bouncer.

danb-cws avatar danb-cws commented on May 26, 2024

I realise now that this is just chrome behaving correctly - in html5 terms a form with email a@b IS valid, and so chrome correctly applies the 'active' css to the submit. (only that bouncer marks the field as invalid as per its rules)
As you mentioned, a js-applied class on the form could be used as a css hook for this state (but it would have to override the rules as described above if you want it all to work no-js)

Thanks for your time!

from bouncer.

cferdinandi avatar cferdinandi commented on May 26, 2024

I gave this a bit more thought, and decided not to add an error class on the form itself.

Bouncer validates individual fields on blur (as opposed to on submit with native form validation), and for fields with errors, it revalidates in real time as the user types.

In order to properly remove an error class from the entire form, Bouncer would need to constantly query the DOM to see if any other fields have errors.

It appears as though your issues are caused by hooking into native validity state for styles instead of (or on top of) using the class hooks Bouncer provides.

I would recommend using the [novalidate] attribute as a style hook in your CSS to suppress those styles after Bouncer initializes. Alternatively, you could add a class to the form after the bouncerInitialized event fires.

from bouncer.

danb-cws avatar danb-cws commented on May 26, 2024

I ended up passing the following pattern:
pattern="[a-zA-Z0-9!#$%&'+/=?^_`{|}~.-]+@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)"
using the 1.4.1 version of Bouncer, this makes Bouncer allow emails of the form a@b so in synch with native html5 validation.
Lets see if the client complains! :)

from bouncer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.