473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

urgent.. email validation



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!
Jul 22 '05 #1
4 1778
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" <mo**************@YAHOO.com> wrote in message
news:uX**************@TK2MSFTNGP10.phx.gbl...


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!

Jul 22 '05 #2
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)
Jul 22 '05 #3


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!
Jul 22 '05 #4
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!

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dcinfinite | last post by:
hi im using asp.net with vb.net. can any1 help me with a validation. i need a validation that can validate..either"A1111111" or "111111111111"i need to validate the first one is.. first character...
6
by: simina | last post by:
Hi... I have a form with 4 number fields: phone area, phone number, cell area, cell number. I did a function that checks the "number" issue for all 4 fields in the same time (because the code is...
2
by: jordan.marton | last post by:
Can someone please take a look at http://epcd.whitecaphosting.com/ on Safari and Firefox and tell me what is wrong with the layout. It looks perfect in IE, and used to look good in FF until I...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
6
by: varkey.mathew | last post by:
Dear all, Bear with me, a poor newbie(atleast in AD).. I have to authenticate a user ID and password for a user as a valid Active Directory user or not. I have created the IsAuthenticated...
7
by: deepagulati | last post by:
Hi, I need an urgent help from you. When we dynamically genrate any list box (Select Box) it shows one default value as selected. Is there any way that we can deselect that value. I...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
2
by: smitanaik | last post by:
hi i want to do validation of datetime in javascripti.e is i want it in this format dd:mm:yyyy:hh:mm:ss plz heklp me out its urgent
7
by: creative1 | last post by:
I am trying form valdiation with javascript but it never call the function. can someone please test this code and see why it is like that. It screwed up my mind. here is my code: <!-- Java Script...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.