RE: validate email in FrontPage form

From: Jim Buyens (news_at_interlacken.com)
Date: 03/05/05


Date: Fri, 4 Mar 2005 16:53:02 -0800

If your two text boxes are named email1 and email2, as in:

<input type="text" name="email1" size="20">
<input type="text" name="email2" size="20">

then add this attribute to your <form> tag

<form onsubmit="chkEmail();" ... >

and add this script to the <head> section.

<script>
function chkEmail()
{
  if (document.forms[0].email1.value == document.forms[0].email2.value)
  {
    document.forms[0].submit();
  }
  else
  {
    alert("E-mail addresses don't agree.");
  }
}
</script>

However, this will only work if the page makes *no* use of the form field
validation built into FrontPage.

Basically, a form can only have one "onsubmit" event handler. That can be
the FrontPage event handler or a custom event handler (as described above)
but not both.

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Windows SharePoint Services Inside Out
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------

> How do I get FP 2002 forms to validate an email address? In other words, I
> want the user to type their email address in twice, in two seperate text
> boxes, and verify that they match. Thanks, DayO



Relevant Pages

  • Re: scripting references Re: sharepoint + unix
    ... | an established script out there that works around the Microsoft shared ... |> Microsoft MVP - FrontPage ... |> | Moving the entire site to a microsoft server is not easy nor feasible- ...
    (microsoft.public.frontpage.programming)
  • RE: Word count?
    ... Add this script anywhere in the page: ... // eliminate leading and trailing white spaces ... If the box shouldn't be blank, check that using standard FrontPage form ... Microsoft MVP ...
    (microsoft.public.frontpage.client)
  • Re: email a friend
    ... Tom Pepper Willett [Microsoft MVP - FrontPage] ... JavaScript Email A Friend Script to my email bar ...
    (microsoft.public.frontpage.client)
  • RE: activate check boxes dependent on radio button selection
    ... If your two check boxes are named chkDoc1 and chkDoc2, add this script ... Microsoft MVP ...
    (microsoft.public.frontpage.client)
  • Re: email a friend
    ... JavaScript Email A Friend Script ... Thomas A. Rowe (Microsoft MVP - FrontPage) ... FrontPage Resources, WebCircle, MS KB Quick Links, etc. ...
    (microsoft.public.frontpage.client)