java script to validate email address and telephone

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
enigma1234567890Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
foobarrConnect With a Mentor Commented:
 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
 
Gurvinder Pal SinghCommented:
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
 
enigma1234567890Author Commented:
this is too many different techonologies I want java Script
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Gurvinder Pal SinghCommented:
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
 
enigma1234567890Author Commented:
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
 
Gurvinder Pal SinghCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.