ch04
This commit is contained in:
47
Chapter ZIPs/JavaScript/ch04/ex_4_27.html
Executable file
47
Chapter ZIPs/JavaScript/ch04/ex_4_27.html
Executable file
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 4.27</title>
|
||||
<script>
|
||||
function getEmail()
|
||||
{
|
||||
var atSign = "@";
|
||||
email = prompt("Enter your email address", " ");
|
||||
numChars = email.length;
|
||||
okSign = 1;
|
||||
for( j = 1; j < numChars; j++) //start at 1 because need at least 1 char before @
|
||||
{
|
||||
if (email.charAt(j) == atSign)
|
||||
{
|
||||
okSign = 0;
|
||||
}
|
||||
}
|
||||
if (okSign == 0)
|
||||
{
|
||||
if (email.charAt(numChars - 4) != ".")
|
||||
{
|
||||
document.getElementById("message").innerHTML ="<h3>You entered " + email + ". This is not a valid email address.</h3>";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("message").innerHTML = "<h3>You entered " + email + ". This is a valid email address.</h3>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("message").innerHTML = "<h3>You entered " + email + ". This is not a valid email address.</h3>";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Enter your contact information</h1>
|
||||
<tr><td><p> </p>
|
||||
<p><input type="button" id="email" value="Begin now" onclick="getEmail();" /></p>
|
||||
</td></tr>
|
||||
<tr><td id ="message"><p> </p></td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user