forked from VishnuSahani/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.html
More file actions
91 lines (85 loc) · 2.85 KB
/
form.html
File metadata and controls
91 lines (85 loc) · 2.85 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
<!DOCTYPE html>
<html>
<head>
<title>Form</title>
<style>
fieldset{ margin: 2%;}
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid blue;
border-radius: 4px;
box-sizing: border-box;
background-color: white;
color: black;
}
input[type=text]:focus {
background-color: lightblue;
}
input[type=submit] {
width: 50%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1> Form</h1>
<form >
<fieldset >
<legend>Primary Details</legend>
<label for ="primaryname">Name:</label>
<input type = "text" name = "Name" id = "primaryName" required><br/>
<label for ="primaryphoneNo">PhoneNo:</label>
<input type = "text" name = "PhoneNo" id = "primaryphoneNo" pattern="[0-9]{10}" required><br/>
<label for ="primaryaddress">Address:</label>
<input type = "text" name = "Address" id = "primaryaddress" required><br/>
<label for = "primaryzip">Zip code:</label>
<input type = "text" name = "Zip code" id = "primaryzip" pattern = "[0-9]{6}" required><br/>
</fieldset>
<input type="checkbox" id="sameAdd" name="same" onchange= "addressFunction()"/>
<label for = "same">Same secondary details.</label>
<fieldset>
<legend>Secondary Details</legend>
<label for ="primaryname">Name:</label>
<input type = "text" name = "Name" id = "secondaryName" required><br/>
<label for ="primaryphoneNo">PhoneNo:</label>
<input type = "text" name = "PhoneNo" id = "secondaryphoneNo" pattern="[0-9]{10}" required><br/>
<label for ="secondaryaddress">Address:</label>
<input type = "text" name = "Address" id = "secondaryaddress" required><br/>
<label for = "secondaryzip">Zip code:</label>
<input type = "text" name = "Zip code" id = "secondaryzip" pattern = "[0-9]{6}" required><br/>
</fieldset>
<input type = "submit" value = "Submit"/>
</form>
// JavaScript Code
<script>
function addressFunction()
{
if (document.getElementById('sameAdd').checked)
{
document.getElementById('secondaryName').value=document.getElementById('primaryName').value;
document.getElementById('secondaryphoneNo').value=document.getElementById('primaryphoneNo').value;
document.getElementById('secondaryaddress').value=document.getElementById('primaryaddress').value;
document.getElementById('secondaryzip').value=document.getElementById('primaryzip').value
}
else
{ document.getElementById('secondaryName').value="";
document.getElementById('secondaryphoneNo').value=""
document.getElementById('secondaryaddress').value="";
document.getElementById('secondaryzip').value="";
}
}
</script>
</body>
</html>