474,044 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Email validator not allowing '.' in email address before '@'

Sorry I crossposted this to java group. Didn't know distinction
between Java & Javascript

Hi,
I'm not a Java script programmer but have this web page with a form
form that
includes a field to input an email address. My problem is that the
validator won't allow addresses that include a '.' before the @ sign to

be entered (such as john....@doman. com)
It seems like (3>intIsDOT-intIsAT) || (4>intLengthA-intIsDOT)){
may be causing the problem. Anyone have an idea that will allow me to
screen out invalid addresses but still allow a . before the @? I would

like to continue using the same script, only modified to allow the '.'
if possible.
Here's the portion of the script that seems to be involved:
function fnEmailValidati on(oTag){
var intLengthA= oTag.value.leng th;
var intIsAT = oTag.value.inde xOf("@");
var intIsDOT = oTag.value.inde xOf(".");
if (intLengthA<6 || intIsAT<1 ||
(3>intIsDOT-intIsAT) ||
(4>intLengthA-intIsDOT)){
return false;
}
var
strTextAfterDot =oTag.value.sub string(intIsDOT +1,intLengthA);
intLengthA= strTextAfterDot .length;
for (var x=0;x<intLength A;x++){
if
(isNaN(strTextA fterDot.substri ng(x,x+1))==tru e) return true;
}
return false;
}

Dec 22 '05 #1
5 1751
gu*****@googlem ail.com wrote:
[...]
I'm not a Java script programmer
I am not either, since there is no "Java script".
but have this web page with a form form that includes a field to input an
email address. My problem is that the validator won't allow addresses
that include a '.' before the @ sign to

be entered (such as john....@doman. com)
Your example address does not conform to RFC2822, the algorithm would
rightfully refuse it.
It seems like (3>intIsDOT-intIsAT) || (4>intLengthA-intIsDOT)){
may be causing the problem. Anyone have an idea that will allow me to
screen out invalid addresses but still allow a . before the @? [...]
<http://groups.google.c om/groups?q=valid+ %22mail+address %22+group%3Acom p.lang.javascri pt&start=0&scor ing=d&>
[overly complicated inefficient code that I refuse to review]


Ever heard of Regular Expressions? Supported since IE3 (August 1996),
NN4 (June 1997).
PointedEars
Dec 22 '05 #2
Thanks, PointedEars. No, I haven't heard of regular expressions. This
isn't my script and it does seem more complicated than other email
validator scripts I've seen on the web. I'm not a web programmer, I
just generally modify existing stuff to come up with what I want if I
need to do something I don't know how to do.

Not being a programmer, I wouldn't necessarily be able to distinguish
the necessary from the unnecessarily complicated. My attempts at
modifying the script have all resulted in the form accepting ANYTHING
in the email address field, unfortunately.

Thanks for the links. I'll do some more looking, and maybe your
reference to "regular expressions" will lead me to something useful.

No big deal. Someone's going to take care of this problem, even if it
isn't me. It's not exactly my webpage, after all.

Thanks again.

Dec 22 '05 #3
<gu*****@google mail.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
Sorry I crossposted this to java group. Didn't know distinction
between Java & Javascript

Hi,
I'm not a Java script programmer but have this web page with a form
form that
includes a field to input an email address. My problem is that the
validator won't allow addresses that include a '.' before the @ sign to

be entered (such as john....@doman. com)
It seems like (3>intIsDOT-intIsAT) || (4>intLengthA-intIsDOT)){
may be causing the problem. Anyone have an idea that will allow me to
screen out invalid addresses but still allow a . before the @? I would

like to continue using the same script, only modified to allow the '.'
if possible.
Here's the portion of the script that seems to be involved:
function fnEmailValidati on(oTag){
var intLengthA= oTag.value.leng th;
var intIsAT = oTag.value.inde xOf("@");
var intIsDOT = oTag.value.inde xOf(".");
if (intLengthA<6 || intIsAT<1 ||
(3>intIsDOT-intIsAT) ||
(4>intLengthA-intIsDOT)){
return false;
}
var
strTextAfterDot =oTag.value.sub string(intIsDOT +1,intLengthA);
intLengthA= strTextAfterDot .length;
for (var x=0;x<intLength A;x++){
if
(isNaN(strTextA fterDot.substri ng(x,x+1))==tru e) return true;
}
return false;
}


Will this help?

<html>
<head>
<title>EmailVal idation.htm</title>
<script type="text/javascript">
function fnFormValidatio n(that) {
var oTag = that.Email;
if (!fnEmailValida tion(oTag)) return false;
return true;
}
function fnEmailValidati on(oTag) {
var regx = /^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/;
if (oTag.value.len gth == 0) {
alert("Email is missing!");
} else if (!regx.test(oTa g.value)) {
alert("Email is invalid!");
}
}
</script>
</head>
<body>
<form name="form1" onsubmit="retur n fnFormValidatio n(this)">
<input type="text" name="Email" size="50" maxlength="50">
<input type="submit" value="Submit">
</form>
</body>
</html>
Dec 22 '05 #4
It just might. Thanks. I'll check it out and see.

Dec 22 '05 #5
JRS: In article <ZZ************ *************** ***@comcast.com >, dated
Thu, 22 Dec 2005 14:04:15 local, seen in news:comp.lang. javascript,
McKirahan <Ne**@McKirahan .com> posted :
Will this help? function fnFormValidatio n(that) {
var oTag = that.Email;
if (!fnEmailValida tion(oTag)) return false;
return true;
}
function fnEmailValidati on(oTag) {
var regx = /^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/;
if (oTag.value.len gth == 0) {
alert("Email is missing!");
} else if (!regx.test(oTa g.value)) {
alert("Email is invalid!");
}
}


Reposting stale code that you've found somewhere, or writing code that
looks like that, is no help to anyone.

That code only allows TLDs of two or three characters.

It also does not allow on the left at least one character, $, which I
know to be valid.

Normally, one would expect a validation function to return a value.

OP : see <URL:http://www.merlyn.demo n.co.uk/js-valid.htm>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dec 23 '05 #6

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

Similar topics

1
2115
by: Bryan Hahn | last post by:
I would like to open our firewall to allow traffic from the w3c validator in our development enviornment. I tried to open port 80 from 18.29.1.50 (validator.w3.org), but that didn't do the trick. What ports/IP address(es) need to be opened in our firewall to allow the validator through?
117
11970
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
13
10830
by: Niki Kovacs | last post by:
Hi, I'm an Austrian writer living in Montpezat (South France). I just installed a local W3C validator on my machine (Slackware 10.1, local Apache server). It's accessible as http://w3c-validator, because I'm on dialup and I want to check pages offline. Unfortunately, URL upload won't work, because the validator doesn't accept any URL's beginning with http://localhost.
7
4476
by: ad | last post by:
Hi, As title, How to determine if a string is an EMail account?
12
1439
by: Amir Ghezelbash | last post by:
Hello every body I had a question I am involved in a project where I need to verify the user's email address by sending them an email and asking them to click on a link. now I have done this but my link is human readable(example validator.aspx?address="blah@blah.com") so any user can just type in their email address into that link and it will validate it for them... now what I want to do is to encrypt this email but most of the...
2
2039
by: Paul Proefrock | last post by:
I am generating an asp page with information on our organizations annual calendar. One of the items presented is the contacts email address. It does appear as a hyperlink but when you click on it, it generates an error page that says "This Action is not allowed" How do I get it to generate the Mailto: link and open email editor. I am using FrontPage2003 to do all this Any ideas?
2
1716
by: gdaalf | last post by:
Folks, Maybe a newbie issue, but I do not quite understand why http://test.aces.uiuc.edu/news/RSS/AcesNewsRSS1.xml will not validate on RSS validator (http://validator.w3.org/feed/). It falls over on line 32, which is <author>dude@uiuc.com The Dude</author> I am not seeing the obvious here. Can some one point it out please?
23
2903
by: codefire | last post by:
Hi, I am trying to get a regexp to validate email addresses but can't get it quite right. The problem is I can't quite find the regexp to deal with ignoring the case james..kirk@fred.com, which is not valid. Here's my attempt, neither of my regexps work quite how I want: import os import re
5
1888
by: Ganesh | last post by:
Hi There, I need to validate email address with regular expression control, i tried something like this ^+*@*\.*$ but i need to validate even if it is blank, it should say invalid email, but don't want to use another requirefield validator
0
10545
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11601
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12020
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8696
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
5413
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.