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.
You could use email_input instead of text_input and 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_input to text_input or remove your pattern, etc…
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: https://en.wikipedia.org/wiki/Email_address#Examples
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 @.
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.
if i click submit with an empty input field I get the email validation error
if i enter something like foo@bar.de and click on submit I get the validation error from the regex (the regex simply checks for an email address starting with the character a
if i enter afoo@bar.de the browser submits the form
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.
That’s rare but, some SMTP define a catchall email address. Meaning all emails using this domain seems valid even if they are not.
I plan to set my email exactly like that. And then I will have emails like hackernews@mydomain.com or linkedin@mydomain.com etc. 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.