• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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,}$/;
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic