Connecting Tech Pros Worldwide Forums | Help | Site Map

urgent.. email validation

VbUser25
Guest
 
Posts: n/a
#1: Jul 22 '05


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.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Sylvain Lafontaine
Guest
 
Posts: n/a
#2: Jul 22 '05

re: urgent.. email validation


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.

"VbUser25" <monika_madan2000@YAHOO.com> wrote in message
news:uXkdrjk5EHA.2568@TK2MSFTNGP10.phx.gbl...[color=blue]
>
>
> 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.
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Evertjan.
Guest
 
Posts: n/a
#3: Jul 22 '05

re: urgent.. email validation


VbUser25 wrote on 20 dec 2004 in
microsoft.public.inetserver.asp.general:
[color=blue]
> 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!
>[/color]

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

That's definitely clientside.
[color=blue]
> function test(src)[/color]

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.
[color=blue]
> thanks to those who respond.[/color]

You're welcome with on topic questions.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
VbUser25
Guest
 
Posts: n/a
#4: Jul 22 '05

re: urgent.. email validation




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



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Blair Bonnett
Guest
 
Posts: n/a
#5: Jul 22 '05

re: urgent.. email validation


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/hojja...on/default.asp
This article shows how to check for basic email address requirements.

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

VbUser25 wrote:[color=blue]
>
> 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
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]
Closed Thread


Similar ASP / Active Server Pages bytes