Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > urgent.. email validation

Reply
Thread Tools

urgent.. email validation

 
 
VbUser25
Guest
Posts: n/a
 
      12-20-2004


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!
 
Reply With Quote
 
 
 
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      12-20-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> 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!



 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      12-20-2004
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
VbUser25
Guest
Posts: n/a
 
      12-20-2004


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!
 
Reply With Quote
 
Blair Bonnett
Guest
Posts: n/a
 
      12-22-2004
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:
>
> 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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying a Validation Error in a Validation Summary Control Lucas Tam ASP .Net 2 02-26-2004 07:49 PM
ASP.NET Web Forms Validation Controls are Server-Side or Client-Side Validation? Matt ASP .Net 14 01-30-2004 09:15 AM
Web form validation vs object validation Colin Basterfield ASP .Net 1 11-29-2003 12:10 AM
validation summary doesnt display when there's client-side validation Libs ASP .Net 0 06-25-2003 03:05 PM
Re: only custom validation control does server side validation? Colin Mackay ASP .Net 0 06-25-2003 07:54 AM



Advertisments