You'll want to replace all instances of \w left of the @ with something
like [a-zA-Z0-9_-] (which is off the top of my head and may need tweaking).
--Ben
Rey Bango wrote:
> Guys I have the following javascript code that validates email
> addresses. The problem is that it won't accept an email that has a dash
> in it (eg: [EMAIL PROTECTED]). Could someone give me some help with
> the regex filter to get it to accept the dash? Thanks.
>
> //Advanced Email Check credit-
> //By JavaScript Kit (www.javascriptkit.com)
> //Over 200+ free scripts here!
>
> var invalidaddress=new Array()
> /*
> invalidaddress[0]="hotmail"
> invalidaddress[1]="rocketmail"
> invalidaddress[2]="yahoo"
> invalidaddress[3]="zdnetmail"
> */
> //extend or shorten this list if neccessary
>
> var testresults
> function isemail(chkemail){
> var invalidcheck=0;
> var str=chkemail
> var
> filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
> if (filter.test(str)){
> var tempstring=str.split("@")
> tempstring=tempstring[1].split(".")
> for (i=0;i<invalidaddress.length;i++){
> if (tempstring[0]==invalidaddress[i])
> invalidcheck=1
> }
> if (invalidcheck!=1)
> testresults=true
> else{
> alert("Please input a more official email address!")
> testresults=false
> }
> }
> else{
> alert("Please input a valid email address!")
> testresults=false
> }
> return (testresults)
> }
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:235209
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54