-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.html
117 lines (117 loc) · 4.38 KB
/
form.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
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Basic Form</title>
<style>
body{
background-image: url('Iron-Man.jpg');
background-repeat: no-repeat;
background-position: center;
}
legend{
color: whitesmoke;
}
input[type=submit]{
background-color:orangered;
}
input[type=submit]{
background-color: maroon;
color: mintcream;
}
input[type=submit]:hover{
background-color:peachpuff;
color: black;
}
input[type=submit]:active{
background-color:lightcoral;
}
ul.navbar{
display: block;
list-style-type: none;
background-color: black;
padding: 10px;
}
li.nav{
display: inline;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 5px;
padding-right: 5px;
background-color: black;
}
li a{
text-decoration: none;
color: white;
}
li.nav:hover{
background-color: grey;
}
li.nav:active{
background-color: red;
}
</style>
</head>
<body>
<ul class="navbar">
<li class="nav"><a href="HTML_Basics.html">Home</a></li>
<li class="nav"><a href="form.html">Register</a></li>
<li class="nav"><a href="details.html">Personal Details</a></li>
</ul>
<form action="details.html" onsubmit="return validate()" method="GET" id="form1">
<fieldset>
<legend>Fill the form</legend>
<label for="name">Enter your name</label><br>
<input type="text" id="name"><br><br>
<label for="phn">Enter your Phone Number</label><br>
<input type="number" id="phn"><br><br>
<label>Select a category</label><br>
<input type="radio" id="bch" name="bch/mst" value="bachelors">
<label for="bch">Bachelors</label><br>
<input type="radio" id="mst" name="bch/mst" value="masters">
<label for="mst">Masters</label><br><br>
<label for="desc">Decription</label><br>
<input type="text" id="desc"><br><br>
<label>Select subjects</label><br>
<input type="checkbox" id="c" value="c">
<label for="c">C Language</label><br>
<input type="checkbox" id="java" value="java">
<label for="java">Java</label><br>
<input type="checkbox" id="python" value="python">
<label for="python">Python</label><br>
<input type="checkbox" id="dmt" value="data_mining">
<label for="dmt">Data Mining</label><br>
<input type="checkbox" id="cn" value=computer_networks>
<label for="cn">Computer Networks</label><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
<script>
function validate(){
var str=document.getElementById("name").value;
var v=/^[A-Za-z]+$/;
var flag=true;
if(!str.match(v)){
alert("Only Characters are allowed in name!");
flag=false;
}
var n=document.getElementById("phn").value;
if(isNaN(n)){
alert("Only numbers are allowed in phone no!");
flag=false;
}
var ch = document.getElementById("c").checked || document.getElementById("java").checked || document.getElementById("python").checked || document.getElementById("dmt").checked || document.getElementById("cn").checked;
if(ch==false){
alert("Atleast one checkbox should be selected!");
flag=false;
}
if(flag==false){
return false;
}
else{
alert("Good");
document.getElementById("form1").submit();
}
}
</script>
</body>
</html>