Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

mask email  RSS feed

 
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I would like to create a field for filling the email with a mask, for example:
The mask should be something like:

where "?" is any string

I'm trying this in the inputMask of primefaces, but I have not found any possibility yet

I do not want to use the "validateRegex pattern" because it does the validation part and I do not want it
I want to keep the email field populated with @gmail.com

Any suggestion?
 
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends a lot on what kind of tag library that is which implements the "p" prefix. There is no difficulty in prepopulating a field with part of an email address, but ensuring that people only enter the prefix before the "@" requires some Javascript. If "gmail.com" is a given, why not have users enter just the first part?
 
Rafael Ra
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need the complete email to be filled, but it happens that some users type only the first part and forget @gmail.com
 
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then as Tim said, why not just add ".gmail.com" at the end on their behalf, if you're only allowing Gmail addresses? Just have them type the first part only.
 
Rafael Ra
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so... this is what I want. This first part will be filled by user

but if I can't do it using mask... what would be the other solution? just javascript?

Thanks!
 
Paul Clapham
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why you need a mask at all. A regular text field should do.
 
Tim Moores
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would just need a simple validation on the server that ensures what the user entered is a proper mail address up to the "@", but you need some form of validation anyway.
 
Rafael Ra
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, some form of validation is necessary

as Tim said, maybe some javascript can be resolve my problem

I will find some examples then

Thanks guys!
 
Paul Clapham
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rafael Ra wrote:yes, some form of validation is necessary



Okay. Then before you start programming, you should decide what that form of validation should be. If it's just "OMG we can't have a field which isn't validated" you should ignore that feeling. You should have a positive reason for validating a field.

Personally I don't see a good reason to validate an e-mail address. If somebody types in an e-mail address which is wrong in some way, that's their problem, they aren't going to get any e-mails from you. And you aren't going to be able to write a validation which notices that they should have typed "overthemoon@gmail.com" rather than "ovrthemoon@gmail.com" -- both of those are valid e-mail addresses. The downside is that you might choose some validation which rejects legitimate e-mail addresses, which is a very bad outcome.
 
Tim Moores
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:The downside is that you might choose some validation which rejects legitimate e-mail addresses, which is a very bad outcome.


To limit the potential of that, it's good to use a trusted third party class like org.apache.commons.validator.routines.EmailValidator.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!