-
-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathForm.html
More file actions
141 lines (133 loc) · 3.45 KB
/
Form.html
File metadata and controls
141 lines (133 loc) · 3.45 KB
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body{
font-family: Calibri, Helvetica, sans-serif;
background-color: pink;
}
.container {
padding: 50px;
background-color: lightblue;
}
input[type=text], input[type=password], textarea {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}
div {
padding: 10px 0;
}
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
.registerbtn {
background-color: #4CAF50;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}
.registerbtn:hover {
opacity: 1;
}
</style>
</head>
<body onload="showGreeting()">
<form onsubmit=" return validateEmpty()">
<div class="container">
<center> <h1> Student Registeration Form</h1> </center>
<hr>
<label> Firstname </label>
<input type="text" name="firstname" placeholder= "Firstname" size="15" onfocus="changeBackgroundColor(this)" />
<label> Lastname: </label>
<input type="text" name="lastname" placeholder="Lastname" size="15" onfocus="changeBackgroundColor(this)" />
<div>
<label>
Course :
</label>
<select id="course">
<option value="Course">Course</option>
<option value="BCA">BCA</option>
<option value="BBA">BBA</option>
<option value="B.Tech">B.Tech</option>
<option value="MBA">MBA</option>
<option value="MCA">MCA</option>
<option value="M.Tech">M.Tech</option>
</select>
</div>
<div>
<label>
Gender :
</label><br>
<input type="radio" value="Male" name="gender" checked > Male
<input type="radio" value="Female" name="gender"> Female
<input type="radio" value="Other" name="gender"> Other
</div>
<label>
Phone :
</label>
<input type="text" name="phone" placeholder="phone no." size="10" onfocus="changeBackgroundColor(this)">
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" >
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" onfocus="changeBackgroundColor(this)" >
<button type="submit" class="registerbtn" onclick="thanku">Register</button>
</form>
</body>
<script>
function validateEmpty(){
var fn=document.getElementsByName("firstname")[0].value;
var ln=document.getElementsByName("lastname")[0].value;
var c=document.getElementById("course").value;
var g = document.querySelector('input[name="gender"]:checked').value;
var p=document.getElementsByName("phone")[0].value;
var em=document.getElementsByName("email")[0].value;
var pass=document.getElementsByName("psw")[0].value;
if (fn == "") {
alert("Please enter your first name");
return false;
}
if (ln == "") {
alert("Please enter your last name");
return false;
}
if (em == "") {
alert("Please enter your email");
return false;
}
if (pass == "") {
alert("Please enter your password");
return false;
}
if (c == "") {
alert("Please choose course");
return false;
}
if (g == "") {
alert("Please choose gender");
return false;
}
if (p == "") {
alert("Please enter phone number");
}
}
function showGreeting() {
alert("Welcome to Home Page");
}
function changeBackgroundColor(element) {
element.style.backgroundColor = "#d9d9d9";
}
function thanku() {
alert("Thank you! your request has been submitted");
}
</script>
</html>