-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform_practice.html
124 lines (96 loc) · 2.66 KB
/
form_practice.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Made with Glitch</title>
<link rel="stylesheet" href="style.css">
<style>
form {
margin: 0 auto;
width: 500px;
padding: 1em;
border: 1px solid #ccc;
border-radius: 1em;
}
ul{
list-style: none;
padding: 0;
margin: 0;
}
form li + li {
margin-top: 1em;
}
label{
display: inline-block;
width: 90px;
text-align: right;
}
input, textarea{
font: 1em sans-serif;
width: 300px;
box-sizing: border-box;
border: 1px solid #999;
}
input:focus textarea:focus{
border-color: #000;
}
textarea{
vertical-align: top;
height: 5em;
}
.button{
padding-left: 90px;
}
button{
margin-left: .5em;
}
#feedback{
background-color: antiquewhite;
position: absolute;
top:0;
left:0;
right:0;
padding: .5em;
display: none;
}
.moveDown{
margin-top: 3em;
}
</style>
</head>
<body>
<div id="feedback"></div>
<form action = "/my-handling-form-page" method= "post">
<ul>
<li>
<label for="Name">Name:</label>
<input type="text" id="name" name="user_name" value="by default this element is defined with this text ">
</li>
<li>
<label for="mail">E-mail:</label>
<input type="email" id="mail" name="user_name" value="by default this element is defined with this text">
</li>
<li>
<label for="msg">Message:</label>
<textarea id="msg" name="user_message">by default this element is defined with this text</textarea>
</li>
<li class="button">
<button type="submit">
send your message
</button>
</li>
</ul>
</form>
<script>
const feedbackElement = document.getElementById('feedback');
const formElement = document.forms[0];
formElement.addEventListener('submit', function(e) {
e.preventDefault();
feedbackElement.innerHTML = 'Hello '+ formElement.user_name.value +'! Thank you for your message. We will get back with you as soon as possible!';
feedbackElement.style.display = "block";
document.body.classList.toggle('moveDown');
});
</script>
</body>
</html>