navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

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

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

Microsoft MVP

 

Validating an Email address Form Field

 
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 >> Validating an Email address Form Field
Page: [1]
 
Peppergal

 

Posts: 2204
Joined: 9/20/2002
Status: offline

 
Validating an Email address Form Field - 3/21/2008 11:59:37   
I've had issues with people not knowing to put an email address in the form field - even though it clearly says "Email Address."

If someone fills in the form without their email address, or if they don't put the @whatever.com (believe it or not, some people have just put their username without the rest of the address) there is no way for me to contact them.

This form is voluntary, if they want to be contacted by us....it's not required, so it's important that they tell us how to contact them.

I tried validating the email address form field so that the form will only go through if the user puts in an actual email address.

If i put the @ sign under "other" , then if there is a dash, underscore, or period in the email address, the form won't go through, as it says only the @ , letters, and digits are allowed....a period or underscore or dash will make it not allowed.

If I put @ . - _ in the "other" field, it seems to let ANYTHING go through, even if there are none of those characters.

I'm at a loss on how to validate this so that only something with a proper email address format goes through.

The form I'm trying to validate is this one:

http://www.paupackgroup.com/sell.htm

I even had one email address come through as "Hawley, PA"

It is surprising but true. LOL

_____________________________

Northeast PA / Poconos/ Lake Wallenpaupack Real Estate
wallenpaupacklakeproperty.com
Karen's Real Estate Blog
coreybryant

 

Posts: 2422
Joined: 3/17/2002
From: Castle Rock CO USA
Status: offline

 
RE: Validating an Email address Form Field - 3/21/2008 15:35:12   
I think this might be the script - so many of them but it might make sure there is a proper email format
<script language="JAVASCRIPT">
<!--
function isEMail( strValue) {
  var objRegExp  = /^[a-z]\w*([.\-]\w+)*@[a-z]\w*([.\-]\w+)*\.[a-z]{2,3}$/i;
  return objRegExp.test(strValue);
}
function validate(theForm){
    if(theForm.EMail.value == ""){
         alert('Please enter a valid E-mail address to submit the form');
         theForm.EMail.focus();
         return false;
    }
            if(!hasValue(theForm.Name.value)){
        alert("Please enter your Name.");
               theForm.Name.focus();
             return false;
}
    if(!isEMail(theForm.EMail.value)){
         alert('Please enter a valid E-mail address to submit the form');
         theForm.EMail.select();
         theForm.EMail.focus();
         return false;
         }
    return true;
}
// -->
</script>


_____________________________

Corey R. Bryant
Merchant Accounts | Toll Free Numbers | My Blog | Expression Web Blog

(in reply to Peppergal)
rdouglass

 

Posts: 9228
From: Biddeford, ME USA
Status: offline

 
RE: Validating an Email address Form Field - 3/22/2008 1:06:12   
An alternative that I use often is ASP once the form is posted. Preference is usually to validate at the client but sometimes you need to validate at the server as well. I use an ASP function like this:

<%Function RegExpTest(sEmail)
RegExpTest = false
Dim regEx, retVal
Set regEx = New RegExp

' Create regular expression for emails
regEx.Pattern ="^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"

regEx.IgnoreCase = true
retVal = regEx.Test(sEmail)
If not retVal Then
exit function
End If

RegExpTest = true
End Function%>

and use it like so:

<%If RegExpTest(Request.form("EmailFormField")) Then
'Do something when valid email
Else
'Do something else
End If%>

Just an alternative. Personally I tend to validate at the server as well since we can't always rely on the JS and it doesn'ty slow things down much at all.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to coreybryant)
Page:   [1]

All Forums >> Web Development >> Microsoft FrontPage Help >> Validating an Email address Form Field
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