Reputation: 9191
I have this code to validate an email address and I think it works fine for normal circumstances
<h:inputText id="email" value="#{myBean.email}"
required="true">
<f:validateRegex pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}" />
</h:inputText>
But if somebody enters this sample email
lòmbardi.Çorneliö@mymail.com
..the regex fails.
Question, is there a way to have a validator allows other ascii characters?
Thanks.
Upvotes: 0
Views: 1137
Reputation: 1108732
Just don't validate only latin characters in A-Z
range. This makes since May 2010 no sense anymore as practically any unicode character is allowed in domain name. It's much better to validate only the occurrence of the @
and .
characters.
<f:validateRegex pattern="([^.@]+)(\.[^.@]+)*@([^.@]+\.)+([^.@]+)" />
Upvotes: 2