Why not to use
/(\w+[\w|\.]*\w+)(@\w+[\w|
?
{2, 4} because there is a top-level domain '.info' which contains four characters.
Also refer to http://wsabstract.com/java
Ñ íàèëó÷øèìè ïîæåëàíèÿìè
Serge
Main Topics
Browse All TopicsHi,
Can anyone tell me how to match the patern of the domain name that has "-" using the regular expression.
See the code bellow:
var myDomains="@test-testing.c
function checkEmailAddress(){
if(emailParts=document.add
{
(myDomains.indexOf(emailPa
else errorMsg +=('\nEmail - \t\t\Please use this email address e.g. . \n\t\tIf you attempt to use any other email address your registration will not be accepted for security \n\t\treasons. Email not allowed: ' +emailParts[2]);
document.adduser.Email.foc
return false;
}
checkEmailAddress('');
Many thanks...
Svjetlana
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Why not to use
/(\w+[\w|\.]*\w+)(@\w+[\w|
?
{2, 4} because there is a top-level domain '.info' which contains four characters.
Also refer to http://wsabstract.com/java
Ñ íàèëó÷øèìè ïîæåëàíèÿìè
Serge
avner
Right, but this wouln't stop any other email address (for example dsfsdf@dsfsdf-sdfasf.com to register. As it said int the error message "If you attempt to use any other email address your registration will not be accepted"
msa2003
Thanks, I have tried this already, but this means that any email address can register containing "-". I just need to read domains from the list and any other that holds "-" should automatically bring error message.
Lana
avner
Right, but this wouln't stop any other email address (for example dsfsdf@dsfsdf-sdfasf.com to register. As it said int the error message "If you attempt to use any other email address your registration will not be accepted"
msa2003
Thanks, I have tried this already, but this means that any email address can register containing "-". I just need to read domains from the list and any other that holds "-" should automatically bring error message.
Lana
avner
If the so-me@tes-ttesting.com should only be allowed not the dsfsdf@dsfsdf-sdfasf.com nor the @dsfsdf-sdfasf.com
Here is the full code:
<html>
<head>
<title>test</title>
<script language="javascript1.2">
function CheckForm () {
var errorMsg = "";
if (document.adduser.Email.va
errorMsg += "\nEmail - Please use this email address e.g. .If you attempt to use any other email address your registration will not be accepted for security treasons.";
}
if (document.adduser.Email.va
errorMsg +="\nEmail - \t\tEnter your Full Email Address";
}
if
((document.adduser.Email.v
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
(document.adduser.Email.va
{
errorMsg +="\nEmail - \t\tInvalid Characters !£$%^&*_+=,?:;'~#";
}
function checkEmailAddress(sEmail)
{
var oRegExp = /^[a-zA-Z][\w\.-]*[a-zA-Z0
if (oRegExp.test(sEmail))
{
return true;
}
else
{
errorMsg +=('\nEmail - Please use this email address e.g. . If you attempt to use any other email address your registration will not be accepted for security treasons. Email not allowed: ' +emailParts[2]);
return false;
}
}
var sEmail="so-me@tes-ttesting
checkEmailAddress(sEmail);
if (errorMsg != ""){
msg = "You have not fully completed the registration form. Please check your details and try again. \n";
errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}
return true;
}
-->
</script>
</head>
<body>
<form name="adduser" method="post" action="test.asp" onSubmit="return CheckForm ()">
<input type="text" name="Email" id="Email" size="22" onBlur="">
<input type="submit" name="Submit" value="Register" OnClick="document.adduser.
</form>
</body>
</html>
cuborvic: your sample EXACTLY duplicates my ;)
Strange. I tried this.
sdfsdf@-.com is not accepted,
sdfsdf@test-testing.com is succesfully accepted with my/cuborvics code.
Svetlana: I'm not sure I understand you. Couldn't you give more detailed description of what do you need?
As I understand, your script does the following: first, it checks if the string matches designed reqular expression, next it breaks the string apart according to the expression and looks if the right part contains an address at the right (';' is used to help do that).
I have a few ideas, but I need more information.
Serge
msa@dsip.net
P. S. Esli problemi s anglijskim, pishi po-russki
var myDomains="@test-testing.c
function checkEmailAddress(){
if(emailParts=document.add
{
if (myDomains.indexOf(emailPa
else errorMsg +=('\nEmail - \t\t\Please use this email address e.g. . \n\t\tIf you attempt to use any other email address your registration will not be accepted for security \n\t\treasons. Email not allowed: ' +emailParts[2]);
document.adduser.Email.foc
return false;
}
checkEmailAddress('');
???
var myDomains="@test-testing.c
function checkEmailAddress(){
if(emailParts=document.add
{
if (myDomains.indexOf(emailPa
else errorMsg +=('\nEmail - \t\t\Please use this email address e.g. . \n\t\tIf you attempt to use any other email address your registration will not be accepted for security \n\t\treasons. Email not allowed: ' +emailParts[2]);
document.adduser.Email.foc
return false;
}
checkEmailAddress('');
???
msa2003
OK this is the scenario. The script checks if the string matches designed reqular expression:
var sEmail="so-me@tes-ttesting
any other string SHOULD NOT be accepted. For example:
so-me@dfsdf-sdfsd.com, so-me@-.com,
sdfsdf@tes-ttesting.com, dsfasdf@sdfsd.com
thanks,
Svjetlana
p.s. ruski nepricam, sorry
msa2003
just tried your code:
var myDomains="@test-testing.c
function checkEmailAddress(){
if(emailParts=document.add
{
if (myDomains.indexOf(emailPa
else errorMsg +=('\nEmail - \t\t\Please use this email address e.g. . \n\t\tIf you attempt to use any other email address your registration will not be accepted for security \n\t\treasons. Email not allowed: ' +emailParts[2]);
document.adduser.Email.foc
return false;
}
checkEmailAddress('');
but somehow this email is accepted:@test-tes-ting.co
var myDomains="@test-testing.c
function errorMessage(email)
{
errorMsg +=('\nEmail - \t\t\Please use this email address e.g. . \n\t\tIf you attempt to use any other email address your registration will not be accepted for security \n\t\treasons. Email not allowed: ' + email);
document.adduser.Email.foc
}
function checkEmailAddress()
{
if(emailParts=document.add
{
if (myDomains.indexOf(emailPa
{
return true;
} else
{
errorMessage(emailParts[2]
return false;
}
} else
{
errorMessage(document.addu
return false;
}
}
:o)
Business Accounts
Answer for Membership
by: avnerPosted on 2003-04-03 at 03:40:39ID: 8260588
Here is a working example :
-9]@[a-zA- Z0-9][\w\. -]*[a-zA-Z 0-9]\.[a-z A-Z][a-zA- Z\.]*[a-zA -Z]$/g;
.com"
<html>
<head>
<title>about:blank</title>
<script language="javascript1.2">
<!-- copyright(c) avcoh@yahoo.com
function checkEmailAddress(sEmail)
{
var oRegExp = /^[a-zA-Z][\w\.-]*[a-zA-Z0
if (oRegExp.test(sEmail))
{
return true;
}
else
{
errorMsg +=('\nEmail - \t\t\Please use this email address e.g. . \n\t\tIf you attempt to use any other email address your registration will not be accepted for security \n\t\treasons. Email not allowed: ' +emailParts[2]);
return false;
}
}
var sEmail="so-me@tes-ttesting
checkEmailAddress(sEmail);
-->
</script>
<style>
</style>
</head>
<body>
</body>
</html>