• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Email validation

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ..
i am facing a problem with a email validation,i wrote a code for checkin whether the email entered is valid or not,rest all is fine but is takes if i give a email as a@b.com.com,while it shud not take the 2nd "com",it takes the enteries w/o any exceptions...
suggest sum methods so tht i can rectify this error..
thanks in advance.......
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reg exp I usuaully use is
var StrRE = /^[\w.]{1,}[@]\w{1,}[.][\w.]{2,}$/;
 
smyle khanna
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi .........
i used the code u mentioned but still there is no change,
it still accepts a@b.com.com as a valid email id.
isnt there any way 2 set it in such a way tht it accepts only email id with one com in its domain?
thanks
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
The reg exp I usuaully use is

var StrRE = /^[\w.]{1,}[@]\w{1,}[.][\w.]{2,}$/;



Hi Eric,
As per this expression, the character "-" is invalid in a email field. What change should I make to the above regular expression to make "-" (or any other character for that matter) as a valid character?

Thanks
 
Clarice Doe
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I figured it out. Will this solve the problem? Please confirm.

var StrRE = /^[\w.\-]{1,}[@][\w\-]{1,}[.][\w.\-]{1,}$/;
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic