angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Form Validation for Email

Open PerfectedApp opened this issue 13 years ago • 8 comments

When an email address is being entered into an input field with type set to email, the validation fails when the Top Level Domain is more than 4 chars long. It also removes the text altogether.

Although a TLD longer than 4 chars is not normal, there are a few and more in the near future. Case in point is 'MUSEUM', which is clearly longer than 4 chars.

I can understand why the text is removed, just as I enter text in an integer input field it's removed, but is not good user experience. If a type'o is made here, the user should be allowed to fix it not re-enter it.

PerfectedApp avatar May 16 '13 07:05 PerfectedApp

I apologize, but this might be an issue with UIWebview. Anyone else can validate this validation issue if it is indeed an Angular issue? :)

PerfectedApp avatar May 16 '13 08:05 PerfectedApp

I just hit this issue also. We scrub our db e-mails in our test environment by appending a .local so that we don't accidentally e-mail people. I just noticed when going to edit these records the e-mail address does not show up on the form. It took awhile to realize this was an issue with angular validation.

While > 4 characters domains is not currently the norm there are a number of domains currently in circulation that are > than 4 characters.

List of current top level domains:

https://data.iana.org/TLD/tlds-alpha-by-domain.txt

J5 avatar May 22 '13 19:05 J5

J5,

How did you hit this issue? I was not able to recreate it besides using Angular in a UIWebView (iOS).

TLD longer than 4 chars will become an issue in the near future. Although these custom domains are extremely expensive, I assume only large organisations will pay for such a service. You can read more about it by a simple Google search. It's my opinion the validation for email should allow for TLD longer than 4 chars.

List of currently pending custom TLD: https://gtldresult.icann.org/application-result/applicationstatus

PerfectedApp avatar May 23 '13 05:05 PerfectedApp

:+1:

There's also an inconsistency between the browser's (Chrome) validation and Angular's.

While "[email protected]" is valid for the browser, it's not for Angular. Hence, the field is not marked as invalid ("Please enter an email address" message) by the browser, but the value is missing from the model.

elado avatar Jun 04 '13 22:06 elado

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

btford avatar Aug 24 '13 00:08 btford

I am using 1.2.0 and this is still an issue for very long TLD's like .construction or .technology in Chrome.

zanedeg avatar Apr 01 '14 19:04 zanedeg

The fix for this is not likely to be backported into 1.2.0, however email validation has been improved somewhat, and is going to be further improved once chrome 35 ships (well, we could ship the remaining fix sooner, I guess).

So, if you use a slightly newer version, 1.2.10, this will work better (and will also invalidate domains which begin with a period, per the RFC). There is just a tiny nudge left to get the validator in sync with the RFC and Chrome, because currently leading and trailing hyphens are totally fine, but this is not actually legal. But you probably don't need to worry about that a whole lot. This was broken in Chrome too, so we fixed it there and I feel like it would be good to keep the projects in sync. But we could ship that fix too.

Anyways, rambling a bit there, but yeah, email regexp works for longer domain names now. There's no restriction regarding TLD length (although Chrome only allows you up to 63 characters per domain label).

Hope that helps.

caitp avatar Apr 01 '14 19:04 caitp

Sick, wasn't expecting it to be backported but wasn't sure what kind of progress (if any) was taking place on this. Thanks for the update.

zanedeg avatar Apr 01 '14 20:04 zanedeg