Create Landing Page for HTML CSS Javascript Bootstrap
- User
Create Landing Page for HTML CSS Javascript Bootstrap
- Assistant
- User
- Assistant
Create Landing Page for HTML CSS Javascript Bootstrap
Creating a landing page involves combining HTML for structure, CSS for styling, JavaScript for interactivity, and Bootstrap to streamline the process with pre-designed components. Here's a basic example of how you can set up a landing page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Landing Page</title>
<!-- Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<style>
body {
font-family: Arial, sans-serif;
}
.hero {
background: url('https://via.placeholder.com/1500x800') no-repeat center center;
background-size: cover;
height: 100vh;
color: white;
text-shadow: 1px 1px 5px rgba(0,0,0,0.7);
}
.hero-text {
padding-top: 150px;
}
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Brand</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
<!-- Hero Section -->
<div class="hero d-flex align-items-center justify-content-center">
<div class="container text-center hero-text">
<h1 class="display-4">Welcome to Our Landing Page</h1>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="#" class="btn btn-primary btn-lg mt-3">Get Started</a>
</div>
</div>
<!-- Features Section -->
<div class="container my-5">
<div class="row">
<div class="col-md-4">
<h3>Feature 1</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum.</p>
</div>
<div class="col-md-4">
<h3>Feature 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum.</p>
</div>
<div class="col-md-4">
<h3>Feature 3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum.</p>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-dark text-white text-center py-3">
<p>© 2023 Your Company. All Rights Reserved.</p>
</footer>
<!-- jQuery and Bootstrap Bundle (including Popper) -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
HTML: The structure of the landing page, organized into various sections using semantic HTML elements like <nav>, <div>, <footer>, etc.
CSS: Custom styling is defined in the <style> tag for additional customization, on top of the Bootstrap styling.
JavaScript and Bootstrap JS: Used for interactivity and to enable Bootstrap components. Here, the scripts are added as external links to the Bootstrap JavaScript library.
Bootstrap: The Bootstrap CSS and JS links are included via CDN for easy integration and use of responsive design and pre-defined styles.
debugging for code
/ Navbar Styles /
.navbar {
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/ Hero Section /
#home {
background: url('https://via.placeholder.com/1920x1080') center center/cover no-repeat;
position: relative;
height: 100vh;
display: flex;
align-items: center;
color: #fff;
text-align: center;
}
#home::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.6);
z-index: 1;
}
#home .content {
position: relative;
z-index: 2;
}
#home h1 {
font-size: 3rem;
margin-bottom: 1rem;
}
#home p {
font-size: 1.2rem;
margin-bottom: 2rem;
}
/ About Section /
#about {
padding: 4rem 0;
}
#about img {
max-width: 100%;
border-radius: 8px;
}
/ Projects Section /
#projects {
padding: 4rem 0;
background-color: #f9f9f9;
}
#projects .card-img-top {
height: 200px;
object-fit: cover;
}
/ Skills Section /
#skills {
padding: 4rem 0;
}
#skills h5 {
margin-bottom: 10px;
}
/ Contact Section /
#contact {
padding: 4rem 0;
background-color: #f9f9f9;
}
/ Footer /
footer {
padding: 2rem 0;
background-color: #333;
color: #fff;
text-align: center;
}
footer a {
color: #fff;
margin: 0 10px;
font-size: 1.2rem;
transition: color 0.3s;
}
footer a:hover {
color: #007BFF;
}
/ Responsive Adjustments */
@media (max-width: 768px) {
#home h1 {
font-size: 2.5rem;
}
#home p {
font-size: 1rem;
}
}
</style>
<!-- Navbar -->
<nav id="navbar" class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="#">[Your Portfolio]</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarContent"
aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarContent">
<ul class="navbar-nav mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#projects">Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#skills">Skills</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Hero Section -->
<section id="home">
<div class="container content">
<h1>Hi, I'm [Your Name]</h1>
<p>A Passionate Web Developer</p>
<a href="#projects" class="btn btn-primary btn-lg">View My Work</a>
</div>
</section>
<!-- About Section -->
<section id="about">
<div class="container">
<h2 class="text-center mb-4">About Me</h2>
<div class="row align-items-center">
<div class="col-md-4">
<img src="https://via.placeholder.com/400" alt="Profile Picture" class="img-fluid rounded">
</div>
<div class="col-md-8">
<p>Hello! I'm [Your Name], a web developer with a passion for creating dynamic and responsive
websites. With a strong foundation in HTML, CSS, JavaScript, and Bootstrap, I build
user-friendly interfaces and seamless user experiences. I enjoy collaborating with clients to
bring their visions to life and continuously learning to stay updated with the latest web
technologies.</p>
<a href="#contact" class="btn btn-outline-primary mt-3">Get in Touch</a>
</div>
</div>
</div>
</section>
<!-- Projects Section -->
<section id="projects">
<div class="container">
<h2 class="text-center mb-4">My Projects</h2>
<div class="row g-4">
<!-- Project 1 -->
<div class="col-md-4">
<div class="card h-100">
<img src="https://via.placeholder.com/400x200" class="card-img-top" alt="Project 1">
<div class="card-body">
<h5 class="card-title">Project One</h5>
<p class="card-text">A brief description of Project One. Highlight the technologies used and
the purpose.</p>
</div>
<div class="card-footer">
<a href="#" class="btn btn-sm btn-primary me-2" target="_blank"><i class="fas fa-eye"></i>
Live</a>
<a href="#" class="btn btn-sm btn-secondary" target="_blank"><i class="fas fa-code"></i>
Code</a>
</div>
</div>
</div>
<!-- Project 2 -->
<div class="col-md-4">
<div class="card h-100">
<img src="https://via.placeholder.com/400x200" class="card-img-top" alt="Project 2">
<div class="card-body">
<h5 class="card-title">Project Two</h5>
<p class="card-text">A brief description of Project Two. Highlight the technologies used and
the purpose.</p>
</div>
<div class="card-footer">
<a href="#" class="btn btn-sm btn-primary me-2" target="_blank"><i class="fas fa-eye"></i>
Live</a>
<a href="#" class="btn btn-sm btn-secondary" target="_blank"><i class="fas fa-code"></i>
Code</a>
</div>
</div>
</div>
<!-- Project 3 -->
<div class="col-md-4">
<div class="card h-100">
<img src="https://via.placeholder.com/400x200" class="card-img-top" alt="Project 3">
<div class="card-body">
<h5 class="card-title">Project Three</h5>
<p class="card-text">A brief description of Project Three. Highlight the technologies used
and the purpose.</p>
</div>
<div class="card-footer">
<a href="#" class="btn btn-sm btn-primary me-2" target="_blank"><i class="fas fa-eye"></i>
Live</a>
<a href="#" class="btn btn-sm btn-secondary" target="_blank"><i class="fas fa-code"></i>
Code</a>
</div>
</div>
</div>
<!-- Add more projects as needed -->
</div>
</div>
</section>
<!-- Skills Section -->
<section id="skills">
<div class="container">
<h2 class="text-center mb-4">My Skills</h2>
<div class="row">
<!-- Skill 1 -->
<div class="col-md-6">
<h5>HTML5</h5>
<div class="progress mb-3">
<div class="progress-bar" role="progressbar" style="width: 90%;" aria-valuenow="90"
aria-valuemin="0" aria-valuemax="100">90%</div>
</div>
</div>
<!-- Skill 2 -->
<div class="col-md-6">
<h5>CSS3</h5>
<div class="progress mb-3">
<div class="progress-bar bg-success" role="progressbar" style="width: 85%;" aria-valuenow="85"
aria-valuemin="0" aria-valuemax="100">85%</div>
</div>
</div>
<!-- Skill 3 -->
<div class="col-md-6">
<h5>JavaScript</h5>
<div class="progress mb-3">
<div class="progress-bar bg-info" role="progressbar" style="width: 80%;" aria-valuenow="80"
aria-valuemin="0" aria-valuemax="100">80%</div>
</div>
</div>
<!-- Skill 4 -->
<div class="col-md-6">
<h5>Bootstrap</h5>
<div class="progress mb-3">
<div class="progress-bar bg-warning" role="progressbar" style="width: 75%;" aria-valuenow="75"
aria-valuemin="0" aria-valuemax="100">75%</div>
</div>
</div>
<!-- Add more skills as needed -->
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact">
<div class="container">
<h2 class="text-center mb-4">Contact Me</h2>
<div class="row justify-content-center">
<div class="col-md-8">
<form id="contact-form" class="needs-validation" novalidate>
<div class="mb-3">
<label for="name" class="form-label">Your Name</label>
<input type="text" class="form-control" id="name" placeholder="Enter your name" required>
<div class="invalid-feedback">
Please enter your name.
</div>
</div>
<div class="mb-3">
<label for="email" class="form-label">Your Email</label>
<input type="email" class="form-control" id="email" placeholder="name@example.com" required>
<div class="invalid-feedback">
Please enter a valid email address.
</div>
</div>
<div class="mb-3">
<label for="message" class="form-label">Your Message</label>
<textarea class="form-control" id="message" rows="5" placeholder="Your message here..."
required></textarea>
<div class="invalid-feedback">
Please enter your message.
</div>
</div>
<button type="submit" class="btn btn-primary">Send Message</button>
<div id="form-messages" class="mt-3"></div>
</form>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer>
<div class="container">
<p>© 2023 [Your Name]. All rights reserved.</p>
<div class="mt-2">
<a href="#" target="_blank"><i class="fab fa-facebook-f"></i></a>
<a href="#" target="_blank"><i class="fab fa-twitter"></i></a>
<a href="#" target="_blank"><i class="fab fa-linkedin-in"></i></a>
<a href="#" target="_blank"><i class="fab fa-github"></i></a>
</div>
</div>
</footer>
<!-- Bootstrap JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JavaScript -->
<script>
// Enable Bootstrap's ScrollSpy
const scrollSpy = new bootstrap.ScrollSpy(document.body, {
target: '#navbar',
offset: 70
});
// Contact Form Validation and Submission
(function () {
'use strict'
// Fetch the form we want to apply custom validation to
const form = document.getElementById('contact-form')
// Event listener for form submission
form.addEventListener('submit', function (event) {
event.preventDefault()
event.stopPropagation()
if (form.checkValidity()) {
// Simulate form submission (e.g., using Fetch API)
const name = document.getElementById('name').value.trim()
const email = document.getElementById('email').value.trim()
const message = document.getElementById('message').value.trim()
// Here, you can implement actual form submission logic (e.g., send to server)
// For demonstration, we'll just display a success message
const formMessages = document.getElementById('form-messages')
formMessages.innerHTML = & lt;div class="alert alert-success" role = "alert" & gt; <br /> Thank you, ${ name } !Your message has been sent successfully.< br /> & lt;/div>
form.reset()
form.classList.remove('was-validated')
} else {
form.classList.add('was-validated')
}
}, false)
})()
</script>
To debug the provided HTML code, let's address a few issues:
CSS Comment Syntax: The comment syntax in your CSS should use /* ... */ for comments. However, you've used slashes for starting comments (e.g., / Global Styles /). Ensure that you replace the slashes with asterisks to properly comment CSS.
JavaScript Code: The JavaScript section contains a string error where HTML tags are not properly closed, specifically in the formMessages.innerHTML line.
Here's the corrected code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>[Your Name] - Portfolio</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Google Fonts (Optional) -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<!-- Font Awesome (Optional for Icons) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<!-- Custom CSS -->
<style>
/* Global Styles */
body {
font-family: 'Roboto', sans-serif;
scroll-behavior: smooth;
}
/* Navbar Styles */
.navbar {
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* Hero Section */
#home {
background: url('https://via.placeholder.com/1920x1080') center center/cover no-repeat;
position: relative;
height: 100vh;
display: flex;
align-items: center;
color: #fff;
text-align: center;
}
#home::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
z-index: 1;
}
#home .content {
position: relative;
z-index: 2;
}
#home h1 {
font-size: 3rem;
margin-bottom: 1rem;
}
#home p {
font-size: 1.2rem;
margin-bottom: 2rem;
}
/* About Section */
#about {
padding: 4rem 0;
}
#about img {
max-width: 100%;
border-radius: 8px;
}
/* Projects Section */
#projects {
padding: 4rem 0;
background-color: #f9f9f9;
}
#projects .card-img-top {
height: 200px;
object-fit: cover;
}
/* Skills Section */
#skills {
padding: 4rem 0;
}
#skills h5 {
margin-bottom: 10px;
}
/* Contact Section */
#contact {
padding: 4rem 0;
background-color: #f9f9f9;
}
/* Footer */
footer {
padding: 2rem 0;
background-color: #333;
color: #fff;
text-align: center;
}
footer a {
color: #fff;
margin: 0 10px;
font-size: 1.2rem;
transition: color 0.3s;
}
footer a:hover {
color: #007BFF;
}
/* Responsive Adjustments */
@media (max-width: 768px) {
#home h1 {
font-size: 2.5rem;
}
#home p {
font-size: 1rem;
}
}
</style>
</head>
<body data-bs-spy="scroll" data-bs-target="#navbar" data-bs-offset="70" tabindex="0">
<!-- Navbar -->
<nav id="navbar" class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="#">[Your Portfolio]</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarContent"
aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarContent">
<ul class="navbar-nav mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#projects">Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#skills">Skills</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Hero Section -->
<section id="home">
<div class="container content">
<h1>Hi, I'm [Your Name]</h1>
<p>A Passionate Web Developer</p>
<a href="#projects" class="btn btn-primary btn-lg">View My Work</a>
</div>
</section>
<!-- About Section -->
<section id="about">
<div class="container">
<h2 class="text-center mb-4">About Me</h2>
<div class="row align-items-center">
<div class="col-md-4">
<img src="https://via.placeholder.com/400" alt="Profile Picture" class="img-fluid rounded">
</div>
<div class="col-md-8">
<p>Hello! I'm [Your Name], a web developer with a passion for creating dynamic and responsive
websites. With a strong foundation in HTML, CSS, JavaScript, and Bootstrap, I build
user-friendly interfaces and seamless user experiences. I enjoy collaborating with clients to
bring their visions to life and continuously learning to stay updated with the latest web
technologies.</p>
<a href="#contact" class="btn btn-outline-primary mt-3">Get in Touch</a>
</div>
</div>
</div>
</section>
<!-- Projects Section -->
<section id="projects">
<div class="container">
<h2 class="text-center mb-4">My Projects</h2>
<div class="row g-4">
<!-- Project 1 -->
<div class="col-md-4">
<div class="card h-100">
<img src="https://via.placeholder.com/400x200" class="card-img-top" alt="Project 1">
<div class="card-body">
<h5 class="card-title">Project One</h5>
<p class="card-text">A brief description of Project One. Highlight the technologies used and
the purpose.</p>
</div>
<div class="card-footer">
<a href="#" class="btn btn-sm btn-primary me-2" target="_blank"><i class="fas fa-eye"></i>
Live</a>
<a href="#" class="btn btn-sm btn-secondary" target="_blank"><i class="fas fa-code"></i>
Code</a>
</div>
</div>
</div>
<!-- Project 2 -->
<div class="col-md-4">
<div class="card h-100">
<img src="https://via.placeholder.com/400x200" class="card-img-top" alt="Project 2">
<div class="card-body">
<h5 class="card-title">Project Two</h5>
<p class="card-text">A brief description of Project Two. Highlight the technologies used and
the purpose.</p>
</div>
<div class="card-footer">
<a href="#" class="btn btn-sm btn-primary me-2" target="_blank"><i class="fas fa-eye"></i>
Live</a>
<a href="#" class="btn btn-sm btn-secondary" target="_blank"><i class="fas fa-code"></i>
Code</a>
</div>
</div>
</div>
<!-- Project 3 -->
<div class="col-md-4">
<div class="card h-100">
<img src="https://via.placeholder.com/400x200" class="card-img-top" alt="Project 3">
<div class="card-body">
<h5 class="card-title">Project Three</h5>
<p class="card-text">A brief description of Project Three. Highlight the technologies used
and the purpose.</p>
</div>
<div class="card-footer">
<a href="#" class="btn btn-sm btn-primary me-2" target="_blank"><i class="fas fa-eye"></i>
Live</a>
<a href="#" class="btn btn-sm btn-secondary" target="_blank"><i class="fas fa-code"></i>
Code</a>
</div>
</div>
</div>
<!-- Add more projects as needed -->
</div>
</div>
</section>
<!-- Skills Section -->
<section id="skills">
<div class="container">
<h2 class="text-center mb-4">My Skills</h2>
<div class="row">
<!-- Skill 1 -->
<div class="col-md-6">
<h5>HTML5</h5>
<div class="progress mb-3">
<div class="progress-bar" role="progressbar" style="width: 90%;" aria-valuenow="90"
aria-valuemin="0" aria-valuemax="100">90%</div>
</div>
</div>
<!-- Skill 2 -->
<div class="col-md-6">
<h5>CSS3</h5>
<div class="progress mb-3">
<div class="progress-bar bg-success" role="progressbar" style="width: 85%;" aria-valuenow="85"
aria-valuemin="0" aria-valuemax="100">85%</div>
</div>
</div>
<!-- Skill 3 -->
<div class="col-md-6">
<h5>JavaScript</h5>
<div class="progress mb-3">
<div class="progress-bar bg-info" role="progressbar" style="width: 80%;" aria-valuenow="80"
aria-valuemin="0" aria-valuemax="100">80%</div>
</div>
</div>
<!-- Skill 4 -->
<div class="col-md-6">
<h5>Bootstrap</h5>
<div class="progress mb-3">
<div class="progress-bar bg-warning" role="progressbar" style="width: 75%;" aria-valuenow="75"
aria-valuemin="0" aria-valuemax="100">75%</div>
</div>
</div>
<!-- Add more skills as needed -->
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact">
<div class="container">
<h2 class="text-center mb-4">Contact Me</h2>
<div class="row justify-content-center">
<div class="col-md-8">
<form id="contact-form" class="needs-validation" novalidate>
<div class="mb-3">
<label for="name" class="form-label">Your Name</label>
<input type="text" class="form-control" id="name" placeholder="Enter your name" required>
<div class="invalid-feedback">
Please enter your name.
</div>
</div>
<div class="mb-3">
<label for="email" class="form-label">Your Email</label>
<input type="email" class="form-control" id="email" placeholder="name@example.com" required>
<div class="invalid-feedback">
Please enter a valid email address.
</div>
</div>
<div class="mb-3">
<label for="message" class="form-label">Your Message</label>
<textarea class="form-control" id="message" rows="5" placeholder="Your message here..."
required></textarea>
<div class="invalid-feedback">
Please enter your message.
</div>
</div>
<button type="submit" class="btn btn-primary">Send Message</button>
<div id="form-messages" class="mt-3"></div>
</form>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer>
<div class="container">
<p>© 2023 [Your Name]. All rights reserved.</p>
<div class="mt-2">
<a href="#" target="_blank"><i class="fab fa-facebook-f"></i></a>
<a href="#" target="_blank"><i class="fab fa-twitter"></i></a>
<a href="#" target="_blank"><i class="fab fa-linkedin-in"></i></a>
<a href="#" target="_blank"><i class="fab fa-github"></i></a>
</div>
</div>
</footer>
<!-- Bootstrap JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JavaScript -->
<script>
// Enable Bootstrap's ScrollSpy
const scrollSpy = new bootstrap.ScrollSpy(document.body, {
target: '#navbar',
offset: 70
});
// Contact Form Validation and Submission
(function () {
'use strict'
// Fetch the form we want to apply custom validation to
const form = document.getElementById('contact-form')
// Event listener for form submission
form.addEventListener('submit', function (event) {
event.preventDefault()
event.stopPropagation()
if (form.checkValidity()) {
// Simulate form submission (e.g., using Fetch API)
const name = document.getElementById('name').value.trim()
const email = document.getElementById('email').value.trim()
const message = document.getElementById('message').value.trim()
// Here, you can implement actual form submission logic (e.g., send to server)
// For demonstration, we'll just display a success message
const formMessages = document.getElementById('form-messages')
formMessages.innerHTML = `<div class="alert alert-success" role="alert"> Thank you, ${name}! Your message has been sent successfully. </div>`
form.reset()
form.classList.remove('was-validated')
} else {
form.classList.add('was-validated')
}
}, false)
})()
</script>
</body>
</html>
/*...*/ syntax.Ensure you replace [Your Name] and [Your Portfolio] with the actual content for the page. Additionally, check the links for images and other resources to make sure they are pulling in the correct content.
Not yet included in a published release.