-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm_validate.html
149 lines (135 loc) · 3.78 KB
/
Form_validate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>JavaScript form validation - checking email</title>
<link rel="stylesheet" href="form-style.css" type="text/css" />
<script>
function ValidateEmail(inputText) {
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (inputText.value.match(mailformat)) {
alert("Valid email address!");
document.form1.text1.focus();
return true;
} else {
alert("You have entered an invalid email address!");
document.form1.text1.focus();
return false;
}
}
</script>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Raleway", sans-serif;
background: #344a72;
color: #fff;
line-height: 1.8;
}
a {
text-decoration: none;
}
#container {
margin: 30px auto;
max-width: 400px;
padding: 20px;
}
.form-wrap {
background: #fff;
padding: 15px 25px;
color: #333;
}
.form-wrap h1,
.form-wrap p {
text-align: center;
}
.form-wrap .form-group {
margin-top: 15px;
}
.form-wrap .form-group label {
display: block;
color: #666;
}
.form-wrap .form-group input {
width: 100%;
padding: 10px;
border: #ddd 1px solid;
border-radius: 5px;
}
.form-wrap button {
display: block;
width: 100%;
padding: 10px;
margin-top: 20px;
background: #49c1a2;
color: #fff;
cursor: pointer;
}
.form-wrap button:hover {
background: #37a08e;
}
.form-wrap .bottom-text {
font-size: 13px;
margin-top: 20px;
}
footer {
text-align: center;
margin-top: 10px;
}
footer a {
color: #49c1a2;
}
</style>
</head>
<body onload="document.form1.text1.focus()">
<div id="container">
<div class="form-wrap">
<h1>Sign Up</h1>
<p>It's free and only takes a minute</p>
<form name="form1" action="#">
<div class="form-group">
<label for="first-name">First Name</label>
<input type="text" name="firstName" id="first-name" />
</div>
<div class="form-group">
<label for="last-name">Last Name</label>
<input type="text" name="lastName" id="last-name" />
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email1" id="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="password" />
</div>
<div class="form-group">
<label for="password2">Confirm Password</label>
<input type="password" name="pasword2" id="password2" />
</div>
<button
type="submit"
name="submit"
value="Submit"
onclick="ValidateEmail(document.form1.email1)"
class="btn"
>
Sign Up
</button>
<p class="bottom-text">
By clicking the Sign Up button, you agree to our
<a href="#">Terms & Conditions</a> and
<a href="#">Privacy Policy</a>
</p>
</form>
</div>
<footer>
<p>Already have an account? <a href="#">Login Here</a></p>
</footer>
</div>
</body>
</html>