Click to See Complete Forum and Search --> : Validate Email Address


pawarrahu
February 2nd, 2001, 07:33 AM
Hello!
I have One problem In Validating the Email Address Entered by User.
Because I realised that the E-mail address Is Invalid(not existing) Only When I mailed that peroson On Email address give by him.
Is There any method by which i can imediately validate the Email Address.
Pls. help me out
Rahul

saurabhN
February 2nd, 2001, 03:33 PM
there are certain ways to validate e-mail address. The easier way would be to check that the input is atleast greater than 10 letters and it contains a '@' and a '.' sign in it . Checking for these options will filter out many invalid entries. If its very critical for you to have the right adress then you will have to write a server side program which extracts the domain from the e-maill address and pings it to see if the domain exixts other way would be to check with internic to see if the domain exists at runtime ...

Saurabh Nandu
mailsaurabhn@webveda.com
http://Learncsharp.cjb.net

tomcat99
February 17th, 2001, 01:27 PM
Here is a set of JavaScript functions I use in my Web apps to check user fields.

function IsNumeric (str) {
r = new RegExp("[^0-9]");

return (!r.test(str));
}

function IsEmpty (str) {
var strObj = new String(str);

r = /(\s+)/g;
strObj = strObj.replace(r, "");
if (strObj.length == 0)
return true;
else
return false;
}

function IsEmail (str) {
// are regular expressions supported?
var supported = 0;
if (window.RegExp) {
var tempStr = "a";
var tempReg = new RegExp(tempStr);
if (tempReg.test(tempStr)) supported = 1;
}
if (!supported)
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
return (!r1.test(str) && r2.test(str));
}

// for US only (999)999-9999
function IsUSPhoneNumber (str) {
if (str == "N/A")
return true;

var r = new RegExp("[0-9]{3}-[0-9]{3}-[0-9]{4}"),
r2 = new RegExp("[0-9]{3} [0-9]{3} [0-9]{4}"),
r3 = new RegExp("[0-9]{3} [0-9]{7}"),
r4 = new RegExp("[0-9]{10}"),
r5 = new RegExp("[0-9]{3}-[0-9]{7}");

return r.test(str) || r2.test(str) || r3.test(str) || r4.test(str) || r5.test(str);
}

Hope that helped.

tomcat

hatchjn
February 19th, 2001, 06:33 PM
How exactly do you write a server side program which extracts the domain from the e-mail address and pings it to see if the domain exists? In other words I need the code. I need to know how to do this using Javascript. Any help would be greatly appreciated.

saurabhN
February 20th, 2001, 10:54 AM
Javascript !!! Thats used for client side programming , Jscript would be a better option . There is no concrete example that i know of , but there is one on www.gotdotnet.com (user upload area) in C# i guess that might help you.



Saurabh Nandu
mailsaurabhn@webveda.com
http://Learncsharp.cjb.net