Hris
I have some troubles with E-mail validations inside of the form:
<%= text_input f, :email, placeholder: "e-mail", class: "form-control", required: true, pattern: (\w+)@([\w.]{2,3})\.([\w.]{2,3}) %>
The browser recognizes the pattern but it does not work properly. It always pops an error.
I tried many different e-mail validations and at the end I get the same result.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cnck1387
You could use
email_inputinstead oftext_inputand it will validate emails for you. Another nice perk of using that field is it optimizes character layouts on mobile devices to make it easier to enter an email address.But, don’t forget to validate your email address on the server side with a changeset. Never trust information from the client directly. Someone could easily change the HTML from
email_inputtotext_inputor remove your pattern, etc..LostKobrakai
Also keep in mind that accurately validating email addresses is still best be done by confirming it via an actual email sent to the address. Regexes so short as yours will never match all the crazy addresses, which are actually valid based on the spec: Email address - Wikipedia
Hris
It works that way.. Kinda.. It stops when I write , for example, “abv@abc” . It does not count the
patern: "...". The validation dissapears at the first letter after @.kannix
Why do you use that pattern? Do you want to restrict the field to some special mail addresses only?
I would suggest to use
email_inputwithout an additional pattern. There is no good regex to test for an email address (read more over here: Stop Validating Email Addresses with Regex by @davidcelis)kannix
And a small tip for working with regex expressions. Use an online tool like https://regex101.com to check and understand the regex term.
By this you will pretty fast find a few of the errors with that regex:
(\w+)@([\w.]{2,3})\.([\w.]{2,3})(\w+)does not include.so something likehris.lastnamein front of the@will not work([\w.]{2,3})matches only 2 or 3 characters so@gmailis not valid for this regex\.([\w.]{2,3})something like a.ninjatoplevel domain will not matchHris
In my case, pattern does not work, although my browser sees it. I tried different regex combinations. I want to restrict the field for specific emails like @gmail.com. I have changeset validation but I also need it to be in the form.
kannix
Can you give more detail on this? Do you get any validation message at all? Do you see an error? Does it submit the form without checking the regex?
What browser are you using? What are the exact steps you are trying?
I just tried an minimal example at https://jsfiddle.net/uq65mwgh/4/
The html i used is this:
This works for me in the following way:
apedromvieira
We have a Global SaaS platform and email is really important to us.
After several issues with non RFC compliant systems (like Sendgrid), we implemented a combination of Trim, Downcase, Regex, Email Checker and Unidecode.
Regex -
Regex.match?(~r/^[A-Za-z0-9\._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$/, email)Email Checker - email_checker | Hex
Unidecode - unidecode | Hex
dimitarvp
Awesome job!
One remark though:
I plan to set my email exactly like that. And then I will have emails like
hackernews@mydomain.comorlinkedin@mydomain.cometc. so I can keep track of which organization got my email from where.Your package wants to deem such addresses invalid? I understand some spam orgs use techniques like these but many people use them with valid reasons.
toraritte
Stackoverflow thread on general email validation: