Click here to Skip to main content
Sign Up to vote bad
good
See more: VB.NET
hi all,

Am using validation control in my project , my problem is email address that is when i enter the valid email address eg: abc@gmail.com then the code will be executed, as it is i have follow the above mail address but slide changes for domain where the mail id is abc@gmail.lkj which is also executed but its not a valid domain name anyhow it will also executed i dont know why? so my problem is if i enter the unknown domain name like .vbk,.nhgfd,.oikhgh etc.... the form will not be execute thats i need. i will need only registered mail id (eg: com,.org,.net etc...) will be executed.please let me know if anybody know this, i tried so many times but i can't, please find the below code ,
 
code:
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript form validation - email validation</title>
<style type="text/css">
li {list-style-type: none;
font-size: 16pt;
}
.mail {
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width: 400px;
background : #D8F1F8;
border: 1px soild silver;
}
.mail h2 {
margin-left: 38px;
}
input {
font-size: 20pt;
}
input:focus, textarea:focus{
background-color: lightyellow;
}
.submit {
font-size: 12pt;
margin-left: 100px;
}
.rq {
color: #FF0000;
font-size: 10pt;
}
</style>
<script type='text/javascript'>
function ValidateEmail(inputText)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(inputText.value.match(mailformat))
{
document.form1.text1.focus();
return true;
}
else
{
alert("You have entered an invalid email address!");
document.form1.text1.focus();
return false;
}
}
</script>
</head>
<body onload='document.form1.text1.focus()'>
<div class="mail">
<h2>Input an email and Submit</h2>
<form name="form1" action="#">
<ul>
<li><input type='text' name='text1'/></li>
<li> </li>
<li class="submit"><input type="submit" name="submit" value="Submit" onclick="ValidateEmail(document.form1.text1)"/></li>
<li> </li>
</ul>
</form>
</div>
</body>
</html>
Posted 24 Sep '12 - 6:04
stellus762

Comments
Marcus Kramer - 24 Sep '12 - 13:32
If you want a "Valid Domain" filter, then you would have to write one. There is no default method or such out there that does this.

1 solution

With the recent changes imposed by ICANN, there is no such thing as an "invalid" top-level domain name any more. Anyone will be able to register just about any top-level domain they want now.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 425
1 OriginalGriff 315
2 Slacker007 240
3 Maciej Los 240
4 Aarti Meswania 210
0 Sergey Alexandrovich Kryukov 8,953
1 OriginalGriff 7,134
2 CPallini 3,758
3 Rohan Leuva 3,036
4 Maciej Los 2,488


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid