Forum Moderators: open
<html>
<head>
<script type="text/javascript">
function checkemail()
{
if(document.forms[0].elements[0].match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/)) || document.forms[0].elements[0].value == "")
{
alert("Valid email Id is filled out");
return true;
}
return false;
}
</script>
</head>
<body>
<form name = "form1" method ="post" action ="#" onsubmit = "return checkemail();">
<p>Email ID
<input type = "text" value =""><br>
<input type ="submit" value = "submit">
</p>
</body>
</body>
</html> <html>
<head>
<script type = "text/javascript">
function checkemail() {
var email = 'email@yourdomain.com';
var emailFilter=/^[a-zA-Z0-9_.-]+@[a-z0-9][a-z0-9\-]{1,64}(\.[a-z]{2,4}|[a-z]{2,3}\.[a-z]{2})$/i;
var validEmail=emailFilter.test(Email);
if (validEmail!=false) {
alert('We Got a Live One!');
} else {
alert('Oops!');
}
}
</script>
</head>
<body>
<form name = "form1" method ="post" action ="#" onsubmit = "return checkemail();">
<p>Email ID
<input type = "text" value =""><br>
<input type ="submit" value = "submit">
</p>
</body>
</html>
<html>
<head>
<script type = "text/javascript">
function checkemail() {
var email = document.getElementById('email').value;
var emailFilter=/^[a-zA-Z0-9_.-]+@[a-z0-9][a-z0-9\-]{1,64}(\.[a-z]{2,4}|[a-z]{2,3}\.[a-z]{2})$/i;
var validEmail=emailFilter.test(email);
if (validEmail!=false) {
alert('We Got a Live One!\n' +email);
} else {
alert('Oops!\n'+email);
}
}
</script>
</head>
<body>
<form name = "form1" id="form1" action ="javascript:void();" onsubmit = "checkemail();">
<p>Email ID
<input type = "text" value =""><br>
<input type ="submit" value = "submit">
</form>
</p>
</body>
</html>
I am sure I am missing something really silly.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function checkemail()
{
if(document.forms[0].elements[0].value.match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/) )
{
alert("Valid email Id is filled out");
return true;
}
if(document.forms[0].elements[0].value == "" )
{
alert("Please enter an email ID");
return true;
}
if(!document.forms[0].elements[0].value.match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/) )
{
alert("Valid email Id is Not filled out");
return true;
}
return false;
}
</script>
</head>
<body>
<form name="form1" action="#" onsubmit="return checkemail();">
<p>Email ID
<input type="text" value=""><br>
<input type="submit" value="submit">
</p>
</form>
</body>
</html>
<html>
<title>IsEmpty And VAlid Email Field Check</title>
<head>
<script type = "text/javascript">
function formValidator()
{
this.isEmailAddress = isEmailAddress;
this.isEmpty=isEmpty;
}
function isEmpty(val) {
if (val == "")
{
return true;
}
else
{
return false;
}
}
function isEmailAddress(val) {
if(val.match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/))
{
return true;
}
else{
return false;
}
}
function checkForm()
{
fv = new formValidator();
if(fv.isEmpty(document.forms[0].elements[0].value))
{
fv.raiseError("The field Email ID is Blank")
}
if(!fv.isEmpty(document.forms[0].elements[0].value) && !fv.isEmailAddress(document.forms[0].elements[0].value))
{
fv.raiseError("Pleae Enter a Valid email ID");
}
}
</script>
</head>
<body>
<form>
<p><label>Email address</label>
<input type = "text" value = "">
<input type = "submit" value = "Go" onsubmit = "return checkForm();">
</p>
</form>
</body>
</html>
Thanks for reading my code all over again.