-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJs_tut6.html
200 lines (158 loc) · 6.29 KB
/
Js_tut6.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<title>Hello, world!</title>
<style>
.container {
background-color: khaki;
padding: 20px 20px;
}
.btncolor{
height:20px;
width:20px ;
}
#blue{
background-color: #AED6F1;/* blue;*/
}
#pink{
background-color: #E891BB;/* pink;*/
}
#red{
background-color: #F5B7B1;/*red;*/
}
#green{
background-color: #ABEBC6;/* green;*/
}
</style>
<script>
function validateform()
{
var msg="Please Enter";
var fname = document.getElementById('fname').value;
var mname = document.getElementById('mname').value;
var lname = document.getElementById('lname').value;
var gender = document.getElementById('gender').value;
var contact = document.getElementById('contact').value;
var email = document.getElementById('email').value;
var address = document.getElementById('address').value;
if(fname=="" || fname==null)
{
// alert('Please Enter First Name');
msg = msg+' First Name\n';
// return false;
}
if(mname=="" || mname==null)
{
// alert('Please Enter Middle Name');
// return false;
msg = msg+' Middle Name\n';
}
if(lname=="" || lname==null)
{
// alert('Please Enter Last Name');
// return false;
msg = msg+' Last Name\n';
}
if(contact=="" || contact==null)
{
// alert('Please Enter Last Name');
// return false;
msg = msg+' contact\n';
}
if(email=="" || email==null)
{
// alert('Please Enter Last Name');
// return false;
msg = msg+' email\n';
}
if(address=="" || address==null)
{
// alert('Please Enter Last Name');
// return false;
msg = msg+' Address\n';
}
if(contact.length!=10)
{
msg = msg+' Valid Contact\n';
}
if(msg!="Please Enter")
{
alert(msg);
return false;
}
}
</script>
</head>
<body>
<div id="container" class="container">
<button class="btncolor" id="blue"></button>
<button class="btncolor" id="pink"></button>
<button class="btncolor" id="red"></button>
<button class="btncolor" id="green"></button>
<h1>Student Registration</h1>
<form action="" onsubmit="return validateform();" method="GET" autocomplete="off" title="Student Registration Form">
<div class="row">
<div class="col-md-5">
<label for="">First Name</label>
<input type="text" name="fname" id="fname" value="" placeholder="First Name" class="form-control" >
<label for="">Middle Name</label>
<input type="text" name="mname" id="mname" placeholder="Middle Name" class="form-control" >
<label for="">Last Name</label>
<input type="text" name="lname" id="lname" placeholder="Last Name" class="form-control" >
<label for="">Gender</label>
<select name="gender" id="gender" class="form-control">
<option value="">Male</option>
<option value="">Female</option>
</select>
<label for="">Contact</label>
<input type="tel" name="contact" id="contact" placeholder="Contact Name" class="form-control"
>
<label for="">Email</label>
<input type="email" name="email" id="email" placeholder="Email Name" class="form-control"
>
<label for="address">Address</label><br>
<textarea name="address" id="address" cols="30" rows="5" class="form-control" ></textarea>
<br>
<div class="form-group">
<input type="submit" value="Submit" class="btn btn-success">
<input type="reset" value="Clear" class="btn btn-light">
</div>
</div>
</div>
</form>
</div>
<script>
// var container=document.getElementById('container');
/* container.addEventListener('click',func_click);
function func_click()
{
console.log("Mouse Clicked..");
}
*/
// container.addEventListener('click',function(){
// console.log('Mouse clicked');
// });
blue.addEventListener('click',function(){
container.style.background='#AED6F1';
container.style.color='black';
});
var pink=document.getElementById('pink');
pink.addEventListener('click',function(){
container.style.background='#E891BB';
container.style.color='white';
});
red.addEventListener('click',function(){
container.style.background='#F5B7B1';
});
green.addEventListener('click',function(){
container.style.background='#ABEBC6';
});
</script>
</body>
</html>