-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
138 lines (119 loc) · 4.21 KB
/
Copy pathindex.html
File metadata and controls
138 lines (119 loc) · 4.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forms</title>
<style>
body{
min-height:100vh;
display:flex;
align-items: center;
justify-content: center;
background:linear-gradient(to bottom left,rgb(223, 61, 88),rgba(226, 212, 12, 0.925));
}
.container{
background-color:white;
width: 550px;
height:355px;
position: relative;
padding: 30px;
margin: 0px;
align-items: center;
}
.row {
display: flex;
}
.column {
padding: 10px;
height: 300px;
width:300px;
margin-top:1px;
}
</style>
</head>
<body>
<div class="container">
<h1 onclick="clickMe()">Registration Form</h1>
<div class="row">
<div class="column">
<form action="thanku.html" >
<label for="fname" ></label>
<input type="text" id="fname" onchange="myFunction(this)" placeholder="First Name" style="width: 200px;"></input>
<br><br>
<input type="date" id="date" onchange="myFunction(this)" placeholder="Birthday" style="width: 200px;"></input>
<label for="date" ></label>
<br><br><br>
<label for="email"></label>
<input type="text" id="email" onchange="myFunction(this)" placeholder="Email" style="width: 200px;"></input><br>
<br>
<label for="sub">Subject</label>
<br><br>
<select name="subjet" onchange="myFunction(this)" id="subject" style="width: 500px; height: 20px;" ><br>
<option value="choose">Choose an option</option>
<option value="Telugu">Telugu</option>
<option value="Hindi">Hindi</option>
<option value="English">English</option>
<option value="Maths">Maths</option>
</select>
<br><br>
<input type="submit" value="Submit" style="background-color: orange;">
</div>
<div class="column">
<label for="lname"></label>
<input type="text" onchange="myFunction(this)" id="lname" placeholder="Last Name" style="width: 200px;" required/><br><br>
<label for="gender">Gender</label><br>
<input type="radio" onchange="myFunction(this)" id="female" name="gender" >
<label for="female">Female</label>
<input type="radio" onchange="myFunction(this)" id="male" name="gender">
<label for="male">Male</label>
<input type="radio" onchange="myFunction(this)" id="other" name="gender">
<label for="female">Other</label><br><br>
<label for="phonenumber"></label>
<input type="tel" onchange="myFunction(this)" id="phonenumber" minlength="10" maxlength="10" placeholder="Phone Number" style="width: 200px;" ></input>
</div>
</div>
</div>
</form>
<script>
function myFunction(event){
var firstName = document.getElementById("fname").value;
var lastName = document.getElementById("lname").value;
var email = document.getElementById("email").value;
var phone = document.getElementById("phonenumber").value;
if(!validateNumber(event)){
alert("enter a valid phoneNumber");
}
if(event.id=="fname" && !validateNames(event)){
alert("enter more than 2 chars and no numbers");
}
if(event.id=="lname" && !validateNames(event)){
alert("enter more than 2 chars and no numbers");
}
if(event.id=="email" && !validateEmail(event)){
alert("enter proper email");
}
console.log(this);
console.log("myFunction is invoke", event);
console.log(event.value, event.id);
console.log(typeof(event.value));
}
function validateNumber(event){
if(event.id=="phonenumber" && (event.value.length!=10 || event.value.match(/[a-zA-Z]/))) return false;
return true;
}
function validateNames(event){
if((event.value.length<3 || event.value.length>20) || event.value.match(/[1-9)]/)) return false;
return true;
}
function validateEmail(event){
if( event.value.match(
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) return true;
return false;
}
function clickMe(event){
alert("clicked registration form")
}
</script>
</body>
</html>