473,320 Members | 2,193 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,320 software developers and data experts.

Specific E-Mail Validation Script

Please could anyone help I need a validation script on and input field
email to include/exclude the below?
If it is even possible even??
Many Thanks in advanced, Regards, Jason

-----------------------------------------------------------------------------

(Note " * " is NOT a wildcard in the instances below)

include:
a-Z 0-1 * _ - @ a-Z 0-1 _ - . a-Z 0-1

exclude:
*@hsbc.com
*@barclays.com
*@hotmail.com

-----------------------------------------------------------------------------

if (theForm.email.value == "")
{
alert("Please enter a valid email");
theForm.email.focus();
return (false);
}

var checkemail = "@.";
var checkStr = theForm.email.value;
var emailValid = false;
var emailAt = false;
var emailPeriod = false;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkemail.length; j++)
{
if (ch == checkemail.charAt(j) && ch == "@")
emailAt = true;
if (ch == checkemail.charAt(j) && ch == ".")
emailPeriod = true;
if (emailAt && emailPeriod)
break;
if (j == checkemail.length)
break;
}

if (emailAt && emailPeriod)
{
emailValid = true
break;
}
}
if (!emailValid)
{
alert("Please enter a valid email");
theForm.email.focus();
return (false);
}

-----------------------------------------------------------------------------

<form name="whitelist" method="post" action="submit.php">
<input name="email" type="text" id="email"
onblur="lowerCase(this.id)">
<i>us**@company.com (*@company.com = anything)</i><br>
<i>Please do <font color="red">NOT</fontadd <u>*@hotmail.com</u,
only to company domains eg. <u>*@scruttonbland.co.uk</u></i><br>
<i>Also please <font color="red">exclude</fontBank email addresses
(@rbs.co.uk @barclays.co.uk @lloydstsb.com @hsbc.co.uk @natwest.com)</
i><br>
<input name="submit" type="submit" id="submit" value="Submit">
Jan 23 '08 #1
3 1699
Please could anyone help I need a validation script on and input field
email to include/exclude the below?

You are wasting your time doing it that way. *Invest a little time in
learning the beginnings of RegExps, and you will soon profit.
As it does seem pretty difficult to get it just right i'm going to try
searching a few places and my result I will post here.

Might try...

Check whole email and accept if they have ¬

a-Z 0-1 * _ - @ .

Check whole email, Must have the below ¬

@ .

Thanks for your reply.

J
Jan 24 '08 #2
On 24 Jan, 10:24, ibizara <ibiz...@googlemail.comwrote:
>Please could anyone help I need a validation script on an input field
>email to include/exclude the below?
You are wasting your time doing it that way. *Invest a little time in
learning the beginnings of RegExps, and you will soon profit.

As it does seem pretty difficult to get it just right i'm going to try
searching a few places and my result I will post here.

Might try...

Check whole email and accept if they have ¬

a-Z 0-1 * _ - @ .

Check whole email, Must have the below ¬

@ .
Achieved what I needed but in PHP rather than JavaScipt

<?php
// Receiving variables
@$email = addslashes($_POST['email']);

if (! ereg('^[*a-z\'0-9]+([._-][*a-z\'0-9]+)*@([a-z0-9]+([._-][a-
z0-9]+))+$', $email)){
include_once("error.inc");
die();
}

if(preg_match('/\*@(hotmail|rbs|barclays|lloydstsb|hsbc|natwest)\. (com|
co\.uk)$/i',$email)){
include_once("not_allowed.inc");
die();
}
?>

But if anyone wants to help convert the above to JS... ?

J


Jan 24 '08 #3
In comp.lang.javascript message <a10b516c-4a7e-42ec-a344-ce264efaa668@u1
0g2000prn.googlegroups.com>, Wed, 23 Jan 2008 09:13:17, ibizara
<ib*****@googlemail.composted:
>Please could anyone help I need a validation script on and input field
email to include/exclude the below?
You are wasting your time doing it that way. Invest the time in
learning RegExps first.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jan 24 '08 #4

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

Similar topics

6
by: Franz Steinhaeusler | last post by:
Hello, with following function, i get a human readable date/time format. mtime = time.strftime(self.timeformat ,time.localtime(st.st_mtime)) However is there a simple solution to get a...
2
by: Brett Gerhardi | last post by:
Hi all, I'm trying to something that I'm sure must be possible within the schema language but I cannot seem to work it out. Briefly, I am defining a multi-tiered base structure - each tier has...
6
by: Mark Cunningham | last post by:
I am curious if there is something that would be considered a proper method for locating small (three to four items) amounts of page specific styling. Or does it really matter in the great scheme...
2
by: Jon Slaughter | last post by:
<I previously posted this in comp.os.misc, but no one answered and its been 3 days... actually no one has posted any messages at all(atleast they are not showing up), so, while it might not be...
5
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long...
3
by: ExclusiveResorts | last post by:
Can the CallContext be used reliably for storing request specific data? We are developing an application library that uses the CallContext to keep an IdentityMap (hashtable of business objects...
4
by: Nalaka | last post by:
Hi, I have some request specific data that gets created in a "early event", that I need to pass around to many other events. I need access to this data during that request. (and more importantly...
2
by: cemlouis | last post by:
Hi, I want to show some specific pages to people that comes to my site from specific urls, I know the variable $_SERVER will be used but how? For ex if the visitor comes from a site that is...
2
by: Gabriele Farina | last post by:
Hi, I'm tring to implement a Singleton object that should be specific for every thread who create it, not global. I tried a solution that seems to work, but I have a very poor knowledge of...
4
by: Pool | last post by:
I tried to connect DB2 (Sitting in Unix server at my client location) using Db2 connect V8. I am getting the following error message. I tried all the possible options BUt the error is same.. See each...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.