Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javscript email checker won't allow numbers

Status
Not open for further replies.

nikky

Programmer
Joined
Feb 7, 2002
Messages
80
Location
US
I have some javascript that I use to test for valid email addresses. I have used it before with success, but on one page it won't allow numbers in email addresses. Here are the code snippets:

<script>
function val(str) {
var objRegExp =

/(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
return objRegExp.test(str);
}
</script>

and on the email form field:

<INPUT TYPE=&quot;text&quot; NAME=&quot;EMail&quot; size=&quot;30%&quot; maxlength=&quot;60&quot;

style=&quot;font-family: arial,verdana; font-size: 11px;&quot; onBlur=&quot;if(!val(this.value)){alert('Invalid Email, Please check

entry!')};&quot;>

Any ideas ?
 
try this:

<script>
function val(str) {
var objRegExp =

/(^[a-z0-9]([a-z0-9_\.]*)@([a-z0-9_\.]*)([.][a-z0-9]{3})$)|(^[a-z0-9]([a-z0-9_\.]*)@([a-z0-9_\.]*)(\.[a-z0-9]{3})(\.[a-z0-9]{2})*$)/i;
return objRegExp.test(str);
}
</script>

=========================================================
if (!succeed) try();
-jeff
 
Thanks, that did the trick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top