-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContactus.php
More file actions
101 lines (97 loc) · 5.08 KB
/
Contactus.php
File metadata and controls
101 lines (97 loc) · 5.08 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
<?php
include_once('header.php');
include('hms/include/config.php');
?>
<!-- section6 - Contact Us -->
<section id="section6" class="contact-us" style="background-color: #fff5f5;">
<div class="container1">
<div class="contact-form">
<br><br>
<h1><center>Contact Us</center></h1>
<br><br>
<form method="POST" enctype="multipart/form-data" id="contactform">
<div class="container" style="width:50%;">
<div class="form-group">
<input type="text" class="form-control" id="name" name="name" placeholder="Name *" required style="height:50px;width:100%;">
<label class="text-danger" id="nameErr"></label>
</div>
<div class="form-group">
<input type="email" class="form-control" id="email" name="email" placeholder="Your Email *" required style="height:50px;width:100%;">
<label class="text-danger" id="emailErr"></label>
</div>
<div class="form-group">
<input type="tel" class="form-control" id="phone" name="phone" placeholder="Mobile Number *" required style="height:50px; width:100%;" pattern="[0-9]{10}">
<label class="text-danger" id="phoneErr"></label>
</div>
<div class="form-group">
<input type="text" class="form-control" id="subject" name="subject" placeholder="Subject *" required style="height:50px;width:100%;">
<label class="text-danger" id="subjectErr"></label>
</div>
<div class="form-group">
<textarea class="form-control" id="message" name="message" placeholder="Your Message *" required style="height:100px;width:100%;"></textarea>
<label class="text-danger" id="messageErr"></label>
</div>
<div class="submit">
<center>
<p class="btnform" style="min-width:50%;">
<button type="submit" id="btnSubmit" class="more_btn button">Send Message</button>
</p>
</center>
</div>
<div id="mail-status"></div>
</div>
</form>
<br><br>
<script>
$(document).ready(function () {
$("#btnSubmit").click(function (event) {
event.preventDefault();
// Clear previous error messages
$("#nameErr, #emailErr, #phoneErr, #subjectErr, #messageErr").text("");
// Basic frontend validation
if($('#name').val().trim() === '') {
$("#nameErr").text("Please provide Name");
return;
}
if($('#email').val().trim() === '') {
$("#emailErr").text("Please provide Email");
return;
}
if($('#phone').val().trim() === '') {
$("#phoneErr").text("Please provide Mobile Number");
return;
}
if($('#subject').val().trim() === '') {
$("#subjectErr").text("Please provide Subject");
return;
}
if($('#message').val().trim() === '') {
$("#messageErr").text("Please provide Message");
return;
}
var data = new FormData($('#contactform')[0]);
$("#btnSubmit").prop("disabled", true);
$.ajax({
type: "POST",
url: "send_email.php",
data: data,
processData: false,
contentType: false,
cache: false,
success: function(response) {
$("#mail-status").removeClass('text-danger').addClass('text-success').html("We have received your enquiry successfully!");
$("#btnSubmit").prop("disabled", false);
$('#contactform')[0].reset();
},
error: function(xhr) {
$("#mail-status").removeClass('text-success').addClass('text-danger').html("Something went wrong.. Please try again!");
$("#btnSubmit").prop("disabled", false);
}
});
});
});
</script>
</div>
</div>
</section>
<?php include_once('footer.php'); ?>