<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Contact Form</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: ‘Segoe UI’, Tahoma, Geneva, Verdana, sans-serif;
}
body {
background-color: #f5f7fa;
color: #333;
line-height: 1.6;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
padding: 30px;
}
h1 {
color: #2c3e50;
margin-bottom: 15px;
font-size: 2.2rem;
}
h2 {
color: #3498db;
margin: 25px 0 15px;
font-size: 1.5rem;
}
p {
margin-bottom: 20px;
color: #555;
}
.divider {
height: 1px;
background: #e0e0e0;
margin: 25px 0;
}
.contact-info {
background: #f8f9fa;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #444;
}
input, textarea {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 16px;
transition: border 0.3s;
}
input:focus, textarea:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
textarea {
min-height: 150px;
resize: vertical;
}
button {
background: #3498db;
color: white;
border: none;
padding: 12px 25px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
font-weight: 600;
transition: background 0.3s;
}
button:hover {
background: #2980b9;
}
.error-message {
color: #e74c3c;
margin-top: 10px;
padding: 10px;
background: #fdedec;
border-radius: 5px;
display: none;
}
.success-message {
color: #27ae60;
margin-top: 10px;
padding: 10px;
background: #eafaf1;
border-radius: 5px;
display: none;
}
.message {
margin-top: 20px;
padding: 15px;
border-radius: 5px;
}
@media (max-width: 600px) {
.container {
padding: 20px;
}
h1 {
font-size: 1.8rem;
}
h2 {
font-size: 1.3rem;
}
}
</style>
</head>
<body>
<div class=”container”>
<h1>Get in touch</h1>
<p>Have questions or want to discuss a project?<br>We’d love to hear from you. Send us a message and we’ll respond as soon as possible.</p>
<div class=”divider”></div>
<div class=”contact-info”>
<h2>Shoaib</h2>
<p>shoaibhossen480@gmail.com</p>
<p>Received and noted with thanks.</p>
<p>Would you like me to make these more formal for business emails or short and casual for quick replies?</p>
</div>
<form id=”contactForm”>
<div class=”form-group”>
<label for=”name”>Your Name</label>
<input type=”text” id=”name” placeholder=”Enter your name” required>
</div>
<div class=”form-group”>
<label for=”email”>Your Email</label>
<input type=”email” id=”email” placeholder=”Enter your email” required>
</div>
<div class=”form-group”>
<label for=”message”>Your Message</label>
<textarea id=”message” placeholder=”Type your message here” required></textarea>
</div>
<button type=”submit”>SUBMIT</button>
<div class=”error-message” id=”errorMessage”>
There was an error trying to send your message. Please try again later.
</div>
<div class=”success-message” id=”successMessage”>
Your message has been sent successfully! We’ll get back to you soon.
</div>
</form>
</div>
<script>
document.getElementById(‘contactForm’).addEventListener(‘submit’, function(e) {
e.preventDefault();
// Simple validation
const name = document.getElementById(‘name’).value;
const email = document.getElementById(’email’).value;
const message = document.getElementById(‘message’).value;
if (!name || !email || !message) {
showError(‘Please fill in all fields’);
return;
}
if (!isValidEmail(email)) {
showError(‘Please enter a valid email address’);
return;
}
// Simulate form submission (in a real scenario, this would be an AJAX call)
const isSuccess = Math.random() > 0.2; // 80% success rate for demo
if (isSuccess) {
showSuccess();
document.getElementById(‘contactForm’).reset();
} else {
showError(‘There was an error trying to send your message. Please try again later.’);
}
});
function isValidEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
function showError(message) {
const errorElement = document.getElementById(‘errorMessage’);
errorElement.textContent = message;
errorElement.style.display = ‘block’;
document.getElementById(‘successMessage’).style.display = ‘none’;
}
function showSuccess() {
const successElement = document.getElementById(‘successMessage’);
successElement.style.display = ‘block’;
document.getElementById(‘errorMessage’).style.display = ‘none’;
}
</script>
</body>
</html>