validate email in FrontPage form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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)
|/---------------------------------------------------
*----------------------------------------------------
 
Back
Top