PDA

View Full Version : Can anybody recommend a free email validate script


bruce
02-23-2003, 01:52 AM
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: yourname@yourdomain.com");
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>



[b]quote:Originally posted by pupu79

Thanks
</blockquote id="quote"></font id="quote">

pupu79
02-23-2003, 11:40 AM
Thanks