Can anybody recommend a free email validate script

Discussion in 'Classic ASP' started by Bruce, Feb 23, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Bruce

    Bruce DiscountASP.NET Staff

    I am not sure if you are using ASP.net. If you are, use the regular expression validation control. Use this as the validation expression

    \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

    You can also use Javascript to valid email

    <script Language="JavaScript">
    function isEmailAddr(email)
    {
    var result = false
    var theStr = new String(email)
    var index = theStr.indexOf("@");
    if (index > 0)
    {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
    result = true;
    }
    return result;
    }

    function FormValidator(theForm)
    {

    if (theForm.email.value == "")
    {
    alert("Please enter a value for the \"email\" field.");
    theForm.email.focus();
    return (false);
    }

    if (!isEmailAddr(theForm.email.value))
    {
    alert("Please enter a complete email address in the form: [email protected]");
    theForm.email.focus();
    return (false);
    }

    if (theForm.email.value.length < 3)
    {
    alert("Please enter at least 3 characters in the \"email\" field.");
    theForm.email.focus();
    return (false);
    }
    return (true);
    }
    </script>



    quote:Originally posted by pupu79

    Thanks
    </blockquote id="quote"></font id="quote">
     
  2. Thanks
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page