urgent.. email validation

V

VbUser25

Hi

Please suggest i think i am doing something wrong. I am calling fucntion
test from another function where i am performing all the validations.I
want to validate the email id.

this is the main function where i perform all sort of mandatory
validation==>
if (document.f.repemail.value != ""){
if(test(document.f.repemail.value=false)) {
alert("Please Enter a valid Email ID!");
document.f.repemail.focus();
}
else {return;}
}


Here is fucntion test:
function test(src)
{ var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
var regex = new RegExp(emailReg);
alert(regex.test(src));
return regex.test(src);
}
I am nto getting validated at all!!! where is hte mistake i am doing.
pls do suggest!

thanks to those who respond.
 
S

Sylvain Lafontaine

You must use / instead of " to enclose your regular expression (and probably
use \ instead of \\) :

var emailReg = /^[\w-_\.]*[\w-_\.]\@[\w]\.+[\w]+[\w]$/

Also, I'm not sure if your regular expression is right for testing all valid
email addresses. Testing all possibilities for a valid email address is a
very difficult subject.

S. L.
 
E

Evertjan.

VbUser25 wrote on 20 dec 2004 in
microsoft.public.inetserver.asp.general:
Please suggest i think i am doing something wrong. I am calling
fucntion test from another function where i am performing all the
validations.I want to validate the email id.

this is the main function where i perform all sort of mandatory
validation==>
if (document.f.repemail.value != ""){
if(test(document.f.repemail.value=false)) {
alert("Please Enter a valid Email ID!");
document.f.repemail.focus();
}
else {return;}
}


Here is fucntion test:
function test(src)
{ var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
var regex = new RegExp(emailReg);
alert(regex.test(src));
return regex.test(src);
}
I am nto getting validated at all!!! where is hte mistake i am doing.
pls do suggest!

This is a ASP [serverside] NG.
if (document.f.repemail.value != "")

That's definitely clientside.
function test(src)

could be serverside jscript,

and if so:
You cannot call a serverside function from clientside
else [as suggested by the alert()]:
Your question is off topic on this NG.
thanks to those who respond.

You're welcome with on topic questions.
 
V

VbUser25

thanks a plenty for responding back.

now i got the error rectified but facing another problem :-( this
function works well but somehow when i write a@gdhd it accepts it! i
feel it should search for a "." at least?? am i right in my thots or
not? if i write a@fhh then it gives the error message!
here is hte piece of code:
if (document.f.repemail.value != ""){
if(!(test(document.f.repemail.value))) {
alert("Please Enter a valid Email ID!");
document.f.repemail.focus();
return;
}
}

function test(src)
{ var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
var regex = new RegExp(emailReg);
return regex.test(src);
}

pls pls do sugest..i am confused
thanks
 
B

Blair Bonnett

As pointed out, this is an ASP (serverside) newsgroup, whereas you seem
to be posting clientside javascript. If you want help with clientside
javascript, you should find a more appropriate newsgroup to post to.

However... if you want to do serverside email validation, check out the
following two articles:

"Powerful Form Validation Using ASP"
http://www.asp101.com/articles/hojjat/formvalidation/default.asp
This article shows how to check for basic email address requirements.

"Validating Email Addresses with ASP"
http://www.asp101.com/articles/hojjat/mxlookup/default.asp
This article shows how to use freely available websites to do an MX lookup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top