-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_task5.html
86 lines (86 loc) · 3.72 KB
/
js_task5.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Task 5</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<script>
function valid(){
if (document.getElementById('name').value==undefined) {
document.getElementById('name').innerHTML="This field is required";
document.getElementById('myName').style.borderColor = "red";
}
if (document.getElementById('email').value==undefined) {
document.getElementById('email').innerHTML="A valid email address is required";
document.getElementById('myEmail').style.borderColor = "red";
}
if (document.getElementById('website').value==undefined) {
document.getElementById('website').innerHTML="A valid url is required";
document.getElementById('myWebsite').style.borderColor = "red";
}
if (document.getElementById('message').value==undefined) {
document.getElementById('message').innerHTML="This field is required";
document.getElementById('myMessage').style.borderColor = "red";
}
}
</script>
</head>
<body>
<div class="justify-content-center">
<form action="#">
<div class="row my-4">
<div class="col-2 text-end">
Name:
</div>
<div class="col-8">
<div class="d-flex">
<input type="text" id="myName">
<p id="name" class="mx-3 text-danger"></p>
</div>
</div>
</div>
<div class="row my-4">
<div class="col-2 text-end">
Email:
</div>
<div class="col-8">
<div class="d-flex">
<input type="text" id="myEmail">
<p id="email" class="mx-3 text-danger"></p>
</div>
</div>
</div>
<div class="row my-4">
<div class="col-2 text-end">
Website:
</div>
<div class="col-8">
<div class="d-flex">
<input type="text" id="myWebsite">
<p id="website" class="mx-3 text-danger"></p>
</div>
</div>
</div>
<div class="row my-4">
<div class="col-2 text-end">
Message:
</div>
<div class="col-8">
<div class="d-flex">
<textarea name="message" id="myMessage" cols="30" rows="3" ></textarea>
<p id="message" class="mx-3 text-danger"></p>
</div>
</div>
</div>
<div class="col-5 text-center">
<button onclick="valid()">
Submit
</button>
</div>
</form>
</div>
</body>
</html>