-1

The following email is not accepted with a period, is this a regular expression issue or some bug.

This works

abcdefg.jijklmn@abcdedghijklmnopgi.com

but the following doesn't (note uppercase letter in the email "A" and "J"), i think that is the problem

Abcdefg.Jijklmn@abcdedghijklmnopgi.com

Html element

<input type="email" class="form-control" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[![\[][1]][1]a-z]{2,3}$" required="" value=""/>

Error below

enter image description here

user580950
  • 3,558
  • 12
  • 49
  • 94
  • Have you tried to split that address into two strings? – Ethan Jul 26 '16 at 14:06
  • @user154248 Split in 2 strings? can you elaborate – user580950 Jul 26 '16 at 14:07
  • Never mind, didn't read your code closely enough. You can create your own `input` instead of the classic `email` field. Check it out here [link](http://stackoverflow.com/questions/14736469/how-to-create-a-custom-input-type) – Ethan Jul 26 '16 at 14:11

2 Answers2

0

It's because your regex doens't allow capitals.. simply allow capitals..

[a-zA-Z0-9._%+-]+@[a-z0-9.-]+\.[![\[][1]][1]a-z]{2,3}$
Joshua Duxbury
  • 4,892
  • 4
  • 32
  • 51
0

Regular expressions for emails can be very difficult. However, you don't actually need to use a pattern to validate emails as type="email" does that for you. Simply remove the pattern entirely and the clients browser will validate the email for you using their in-built regex

<input type="email" class="form-control" name="email" required="true" value=""/>

I can't actually seem to get email validation to work with the pattern attribute at all, as I think it's competing with type="email".

Connor Bell
  • 154
  • 1
  • 1
  • 10