a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

E-mail validation in frontpage

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Microsoft FrontPage Help >> E-mail validation in frontpage
Page: [1]
 
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
E-mail validation in frontpage - 11/26/2006 11:21:22   
Hello,

I'm looking like crazy on the internet to solve my problem, but I can't get the right answer, so I decided to write.

I made a form in frontpage. I would like that people write a correct mail address in the form before they can send it. Is there any system to get a message if they write a wrong mail address in the form.

Thank you in advance for your help.

:)

Bernard
jaybee

 

Posts: 14207
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 11:54:02   
It depends what you mean by wrong email address.

You can check the format is correct but checking whether it's a real address is darn near impossible.

There are lots of form scripts around that you can grab for free that do format validations it just depends what your host is and what you can use as a scripting language.

You can start by looking at this page this is fine if you're on a Windows host as it uses asp. If you're on a Unix/Linux host and need php then I suggest you go and get Mike Cherim's form.

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to bvdhaegen)
Tailslide

 

Posts: 6366
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 11:58:09   
Stick the following in your page head:

<script type="text/javascript">

<!--
function Form1_Validator(theForm)
{
// check if email field is blank
 if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }


  // test if valid email address, must have @ and .
  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 both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
		EmailValid = true
		break;
	}
  }
  if (!EmailValid)
  {
    alert("The \"email\" field must contain an \"@\" and a \".\".");
    theForm.Email.focus();
    return (false);
  }
	}
//--></script>


And add the following into your form tag:

 onsubmit="return Form1_Validator(this)" 


so it looks sort of like this:

<form action="whatever.html" method="POST"  onsubmit="return Form1_Validator(this)" > 


That script basically ensures that people must write something in the email field and it must have both "@" and a "." in it. Obviously people can still get round this if they really want to - but you can't stop people spoofing the field if they're determined and being Javascript they can just switch Javascript off to bypass it so if you really want good security you need to go server-side like PHP.

Edit: oops - Jaybee beat me to it!

_____________________________

Little Blue Plane Web Design | Land Rover project

:)

(in reply to bvdhaegen)
jaybee

 

Posts: 14207
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 11:59:31   
:)

or you can use javascript.

:)

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to Tailslide)
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 12:17:15   
Hello,

Thanks to both of you for your help.

Yes I just want to make sure that people make the effort to write an e-mail address instead of just writing "blabla". Of course I don't know if it is a valid address or not, but this is OK. As long as there is an "@" and a ".", it is fine.

Unfortunatelly, I'm not that good in web design. SO I still have some questions with the script.

I suppose I have to put it after "body", but in "form" or before or after it? Also I don't really know what I have to change in the script so that it works for me. Than I see text between {}, I suppose I have to delete this.

Would be very nice if you could tell me a little more about how it works.

Thank you, Bernard

(in reply to bvdhaegen)
Tailslide

 

Posts: 6366
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 12:32:18   
When you look at your webpage in code-view you'll see the following (give or take a few tags)

<html>
<head>
<META stuff here>

</head>
</body>

your site stuff goes here including the form

</body>
</html>


Paste ALL of the Javascript bit (the first bit) just before the </head> tag.

You'll see the form opening tag which will start with <form just paste the second bit in there.

You don't need to change anything in the script it will work for any form. All you have to do is ensure that the input field for the email address has name="Email" so that the validation script knows which input field to check. So it'd look like this:

<input type="text" size="60" name="Email" >


You can change the size to match your other fields.

_____________________________

Little Blue Plane Web Design | Land Rover project

:)

(in reply to bvdhaegen)
womble

 

Posts: 5721
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 12:37:17   
This bit of code that Tailslide describes needs to go in the <head> of the page - that is, above the bit that says
</head>
<body>
...your page here

quote:

ORIGINAL: Tailslide

Stick the following in your page head:

<script type="text/javascript">

<!--
function Form1_Validator(theForm)
{
// check if email field is blank
 if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }


  // test if valid email address, must have @ and .
  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 both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
		EmailValid = true
		break;
	}
  }
  if (!EmailValid)
  {
    alert("The \"email\" field must contain an \"@\" and a \".\".");
    theForm.Email.focus();
    return (false);
  }
	}
//--></script>
[/code]

It can go anywhere above the </head> tag

As for the other bit, that's the bit that tells the form that when the user presses submit, to execute the javascript that you've just put in the <head> section of the page. As Tail said, you need to add this into the form tag, which is at the top of the block of code for your form.

 onsubmit="return Form1_Validator(this)" 


quote:

so it looks sort of like this:

<form action="whatever.html" method="POST"  onsubmit="return Form1_Validator(this)" > 


Yours will probably look a bit different if it's a Frontpage generated form, but it will have a form action and method as well as the other bits and pieces Frontpage puts in, but as long as you've got onsubmit="return Form1_Validator(this) within that tag it'll work. Just remember the actual javascript code needs to go in the <head> of your page, above the <body>, and there's nothing you have to delete. The only bit you'll have to change (or rather leave as it is) is the form's action, which Frontpage has already put in for you - if you just paste onsubmit="return Form1_Validator(this) into that tag, you shouldn't have to change anything in your existing code, just add those two bits.

<edit> Beaten to it by Tail! :)</edit>

_____________________________

~~ "A cruel god ain't no god at all" ~~
~~ Erase hate. Practice love. ~~
:)

(in reply to Tailslide)
jaybee

 

Posts: 14207
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 12:42:57   
quote:

<edit> Beaten to it by Tail! :)</edit>
She keeps doing that. :)

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to womble)
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 14:03:33   
Thank you a lot for your help.
I did what you wrote, but it still looks as if it does not work.
I have onsubmit="return FrontPage_Form1_Validator(this)"
The name of the field is Email as you wrote.
OK maybe I past my code here so you can see what is wrong.
Thanks a lot... Bernard


(in reply to jaybee)
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 14:10:13   
OK this code is too large. I can not send it.
What should I do??
Bernard

(in reply to bvdhaegen)
womble

 

Posts: 5721
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 14:49:07   
If it's live on the server, post a link to the page - just post the url of the page - we can view the source code from there. Alternatively you can copy and paste the code for the page between code tags - if you press the button on the posting form that's like this: <% - that'll insert code tags into your post. Just paste your page code between those two tags and it should show up okay.

_____________________________

~~ "A cruel god ain't no god at all" ~~
~~ Erase hate. Practice love. ~~
:)

(in reply to bvdhaegen)
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 17:57:44   
OK maybe more easy to send the link to the page:
Of course I did not add the code I got here, but I will do it.
The link:
http://www.guesthousemongolia.com/mongolia-page/guesthouse/en_contact.htm
Thank you

(in reply to womble)
womble

 

Posts: 5721
Joined: 3/14/2005
From: Living on the edge
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 19:10:33   
Well for a start you've got the javascript in the <body> section of the page and not the <head>. The field's called 'E-mail' and not 'Email'. That's why it's not working.

_____________________________

~~ "A cruel god ain't no god at all" ~~
~~ Erase hate. Practice love. ~~
:)

(in reply to bvdhaegen)
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 19:19:35   
Thank you very much for your help.
I will have a look.

(in reply to womble)
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 19:26:38   
So I just looked again and in fact I did not load the page with the changes.
Now I loaded the page with the changes.
It is in the HEAD and with code Email.
But it still does not work.
Mayeb you could have a look again now.
Thank you for your help.
Bernard

(in reply to womble)
bvdhaegen

 

Posts: 8
Joined: 11/26/2006
Status: offline

 
RE: E-mail validation in frontpage - 11/26/2006 19:30:28   
but the most funny is that since I added those codes, in the mail I get, there is even not line "Email" any more. I get this now:

name: bern

acc. nb of nights: Select

acc. nb of people: Select

nb of train tickets: Select

train to: Select

found us: Acticle

b1: Submit

(in reply to womble)
octavious

 

Posts: 68
Joined: 2/10/2005
From: Northern California
Status: offline

 
RE: E-mail validation in frontpage - 1/16/2007 1:35:40   
Great script! just what I was looking for. However, I can get this script to work but when I use the builtin Frontpage validation for the other fields, this script stops working. Does Frontpages "web bots" kill this script? Or am I doing something wrong?

Octavious

(in reply to Tailslide)
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> Microsoft FrontPage Help >> E-mail validation in frontpage
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts