|
| |
|
|
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
|
|
|
|
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
|
|
|
|
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. ~~
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
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
|
|
|