-
Notifications
You must be signed in to change notification settings - Fork 54
/
eszveare-assignment2.html
89 lines (76 loc) · 2.27 KB
/
eszveare-assignment2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<!-- there should be an html tag here, but that was my mistake -->
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery-min.js"></script>
<script type="text/javascript" src="script.js"></script>
<title>Eaton's Page</title>
<!-- Ideally, you would track the validity of the form with a variable
and accumulate all the error messages together, so the user
doesn't have to submit the form repeatedly. Also, inserting
HTML into the page is usually preferable to using alert() -->
<script type="text/javascript">
function ShowAlert(Text)
{
alert("Here is a message!");
}
function ValidateForm()
{
var a = document.forms["MyForm"]["FN"].value;
if (a == null || a == "")
{
alert("Name must be filled out.");
return false;
}
var b = document.forms["MyForm"]["Cell"].value;
if (b == null || b == "")
{
alert("Phone must be filled out.");
return false;
}
var c = document.forms["MyForm"]["SpamCheck"].value;
if (c != "four")
{
alert("Incorrect answer to 2 + 2!");
return false;
}
var d = document.forms["MyForm"]["Age"].value;
if (d == null || d == "")
{
alert("Age must be filled out.");
return false;
}
return true;
}
</script>
</head>
<body>
<div id="content">
<form id="MyForm" method="POST" onsubmit="return ValidateForm()" action="http://symlink.dk/code/php/submit/">
Name: <input type="text" id ="s" name="FN"></input>
<!-- <br></br> or shorthand <br /> -->
</br>
<!-- also make sure you close your input tags
(<input .../> or <input ...>...</input>) -->
Phone number: <input type="tel" name="Cell">
</br>
What is 2 + 2?
<select name = "SpamCheck">
<option value="five">5</option>
<option value="four">4</option>
</select>
</br>
Age: <input type="number" name="Age" min="1" max="99">
</br>
<input type="submit"></input>
</form>
</br>
<button type="button" onclick="ShowAlert()">Show a Message</button>
</br>
<div id="HideText">This is some annoying text that shouldn't be here!</div>
<button type="button" onclick="$('#HideText').fadeOut();">Hide Annoying Text</button>
<button type="button" onclick="$('#HideText').fadeIn();">Show Annoying Text</button>
</div>
</body>
</html>