-
Notifications
You must be signed in to change notification settings - Fork 0
/
contactme.html
110 lines (110 loc) · 3.88 KB
/
contactme.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
<!DOCTYPE html>
<html>
<head>
<title>Portfolio</title>
<link rel = "icon" href ="C:\Users\Raghav Sekhri\Pictures\Camera Roll\computer.png" type = "image/x-icon">
<link rel="stylesheet" href="contactme.css" media="all">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
<script type="javascript" src="portfolio.js"></script>
</head>
<body>
<div class="header">
<div class="header-logo">
<a href="portfolio.html"><img src="logo1.png" height="50px" width="250px"></img></a>
</div>
<div class="header-list">
<ul>
<font style="font-family:comic sans ms;">
<li></li>
<li></li>
<li></li>
<li><a href="about.html"><button class="button"><span>About</span></button></a></li>
<li></li>
<li></li>
<li><a href="projects.html"><button class="button"><span>Projects</span></button></a></li>
<li></li>
<li></li>
<li><a href="contactme.html"><button class="button"><span>Contact Me</span></button></a></li>
</font>
</ul>
</div>
</div>
<div class="main">
<form class="contact-form" onsubmit="return formValidtor()">
<h1 align="center">Contact Me</h><br>
<div class="border"></div>
<input type="text" id="firstname" class="contact-form-text" placeholder="Your name"><br>
<input type="email" id="emails" class="contact-form-text" placeholder="Your email"><br>
<input type="text" id="phone" class="contact-form-text" placeholder="Your phone"><br>
<textarea class="contact-form-text" placeholder="Your message"></textarea><br>
<input type="submit" class="contact-form-btn" value="Send">
</form>
</div>
<script>
function formValidtor()
{
var firstname = document.getElementById("firstname");
var emailss = document.getElementById("emails");
var phone = document.getElementById("phone");
if(isAlphabet(firstname, "Please enter only letters for your name"))
{
if(emailValidator(emailss, "Please enter a valid email address"))
{
if(lengthRestriction(phone, 10))
{
return true;
}
}
}
return false;
}
function isAlphabet(elem, helperMsg)
{
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function emailValidator(elem, helperMsg)
{
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(elem.value.match(emailExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function lengthRestriction(elem, max)
{
var abc=/6[0-9]+$/;
var uInput = elem.value;
if(uInput.length == max)
{
if(elem.value.match(abc))
{
return true;
}
}
else
{
alert("Please enter a valid phone number");
elem.focus();
return false;
}
}
</script>
</body>
</html>