Solved

java script to validate email address and telephone

Posted on 2011-03-18
6
217 Views
Last Modified: 2012-05-11
I am looking for an example of some java script to validate a user entered a telephone number and a email address correctly anyone got any good examples or sites with code I can check
0
Comment
Question by:enigma1234567890
  • 3
  • 2
6 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35165777
check this for email validation
http://www.roseindia.net/ajax/jquery/validate-email-address.shtml

what is the format of telephone number you are looking for?
0
 

Author Comment

by:enigma1234567890
ID: 35167192
this is too many different techonologies I want java Script
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35167238
that is javascript only, let me make it simpler for you

var str = "sadasd@asd.dfd";
var myArray = str.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/g)

if ( myArray != null)
{
alert("valid email");
}
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:enigma1234567890
ID: 35167365
what i really nned to know is if i have this code how do i convert it to do regex expressions

if (document.x.email.value ==""){
alert("Please enter email address");
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35167407
function isvalidEMail(emailStr)
{
   var myArray = emailStr.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/g);

    if ( myArray != null)
    {
          return true;
    }
    return false;  
}


var emailStr = document.x.email.value;
if ( emailStr =="" && !isvalidEMail(emailStr)){
alert("Please enter email address");

0
 
LVL 7

Accepted Solution

by:
foobarr earned 500 total points
ID: 35183310
 function ValidateEmailAddress(eAddy) {
            var pattern;

            pattern = /^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,10})$/;

            try {
                if (eAddy == "") {
                    return false;
                }
                else {

                    return pattern.test(eAddy);

                }
            }
            catch (e) {
                 alert("error:" + e);
            }
        }
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now