-----Original Message-----
Is there a utility to use in FP2002 that will force an
e-mail address in a front page form field to be formated
correctly?
No.
That is, to make sure it has (e-mail address removed)?
I understand, but no.
Then, is there another one that will compare two form
fields to make sure they are identical?
No.
Put simply, when a potential customer enters an e-mail
address in a field, I want to make sure it is at least
formated correctly. Then, in the "re-enter e-mail
address" form field, I want to make sure the two
addresses are the same or the form won't be submitted.
Any ideas?
Actually, yes.
1. In HTML view, add the following attribute to the text
box for the E-Mail address:
onblur="valEmail(this);"
2. Add the following script to the <head> section of
your page:
<script>
function valEmail(txtBox) {
if (txtBox.value == ""){
return 0;
}
re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
if (re.test(txtBox.value) == false) {
alert("E-Mail Address '" + txtBox.value +
"' is invalid.");
txtBox.focus();
txtBox.select();
}
}
</script>
3. Switch to Design view.
4. Right-click the text box and then choose Form Field
Properties.
5. Click the Validate button.
6. Set Data Type to Text and then, under Data Length,
select Required.
7. Click OK and OK.
FYI, the onblur event occurs whenever the text box loses
focus (such as when the visitor tabs to or clicks another
form field). When that event occurs, the valEmail
function allows the field to be blank, but otherwise
matches its value to a so-called "regular expression"
pattern. If the pattern matches, fine. Otherwise, the
function displays a message box and returns focus to the
text box.
The reason for allowing a blank entry is that the visitor
may decide not to fill out the form, and to click some
other hyperlink instead. A blank entry provides a means
of escape.
In any case, the FrontPage validation rule prevents
actually submitting the form without a blank e-mail
address. This is a rule you need to have anyway, in case
the visitor never tabs to the e-mail text box.
Custom validation scripts and FrontPage validation
generally have a hard time coexisting. This approach
seems to be OK, though, because the custom validation
occurs when the form field loses focus, and the FrontPage
validation occurs when the visitor submits the form.
Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| 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)
|/---------------------------------------------------
*----------------------------------------------------