Click here to Skip to main content
12,301,394 members (64,562 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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:04am
stellus1.2K
Comments
Marcus Kramer 24-Sep-12 13:32pm
   
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
Top Experts
Last 24hrsThis month


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100