Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 20th, 2003, 08:33 AM
Registered User
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checking email fields

Hi,

Does anyone have a bit of ASP to check a: whether an email address is valid,eg. contains characters and @ and nothing weird and b: checks a second field where the user re-enters the email address against the first. Looked and looked on the web but I can't find anything ... probably me :(

Thanks
 
Old October 20th, 2003, 01:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

There is no magic answer given the variety of possible email address formats, there are several validation routines - see http://www.google.com/search?sourcei...idation+asp%22 and http://www.google.com/search?sourcei...+validation%22 - which simply tell you that an address COULD be valid, but the only way to know for sure is to email it.
 
Old October 23rd, 2003, 01:51 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Surendran</title>
</head>
<script language=javascript>
function ddd()
{
var theForm=document.form1
if(document.form1.mail.value =="")
{
alert("Please Enter Your Email Address");
document.form1.mail.focus ();
return
}

  else if (theForm.mail.value!= "")
  {

  var mail1=theForm.mail.value;
  var i1 = mail1.indexOf('@');
  var i2 = mail1.lastIndexOf('@');
  var i3 = mail1.indexOf('.');
  var i4 =(i1-i3);

  if (mail1.length<=5)
  {
  alert("Your E-mail address is too small");
  theForm.mail.focus();
  return ;
 }

    if(i1==-1)
 {
  alert(" E-mail address must have a '@' ");
  theForm.mail.focus();
 return ;
  }
  if(i1<2)
 {
  alert(" E-mail address invalid ");
  theForm.mail.focus();
 return;
   }

    if(i3==-1)
  {
  alert(" E-mail address must have a '.' ");
  theForm.mail.focus();
 return
  }
 ch = mail1.charAt(mail1.length-1);
 if (ch==".")
  {
    alert(" E-mail address cannot contain '.' in end");
    theForm.mail.focus();
    return
 }
if(i1!=i2)
{
 alert(" E-mail address cannot contain two '@' signs");
 theForm.mail.focus();
 return
  }
 arr=mail1.split("@");
 var i5=arr[1].indexOf('.');
 if(i5==-1)
 {
 alert(" E-mail address must have a '.' after @ sign ");
 theForm.mail.focus();
 return
 }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎà ÃÃ‘Ã’Ã“Ã”Ã•Ã–Ã˜Ã™ÃšÃ›ÃœÃÃžÃŸÃ Ã¡Ã¢Ã£Ã¤Ã¥Ã¦Ã§Ã¨Ã ©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã°Ã±Ã²Ã³Ã´ÃµÃ¶Ã¸Ã¹ÃºÃ»Ã¼Ã½Ã¾012345678 9-_.@";
  var checkStr = theForm.mail.value;
  var allValid = true;
  for (i = 0; i < checkStr.length; i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit and \"@\" characters in the \"E-mail\" field.");
    theForm.mail.focus();
    return
  }
  }
document.form1 .action ="http://www.mathi.8m.con"
document.form1 .submit ();
}
//-->
</script>
<body>

<form name=form1 method="POST">
 <p align="center"><input type="text" name="mail" size="20"><br>
 <input type="button" onclick="ddd()" value="Submit" name="B1"></p>
 <p align="center">Hello Click Submit button<br>
 visit my web <a href="http://www.mathi.8m.com">http://www.mathi.8m.com</a></p>
</form>
</body>

</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Function for Checking Email Syntax atr000 Excel VBA 0 July 18th, 2006 12:13 PM
Error checking for table fields null value constra method Access VBA 1 September 26th, 2005 09:00 PM
checking fields value from rs lucian Dreamweaver (all versions) 4 July 24th, 2004 02:23 AM
Form validation and email checking visionary Beginning PHP 9 July 15th, 2003 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.