Skip to content
Permalink
5edcea6126
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
43 lines (33 sloc) 1.34 KB
<!DOCTYPE html>
<html>
<head>
<title>Contact Information Form</title>
</head>
<body>
<h1>Contact Info</h1>
<form id="contactForm">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br><br>
<label for="subject">Subject:</label><br>
<input type="text" id="subject" name="subject" required><br><br>
<label for="message">Message:</label><br>
<textarea id="message" name="message" required></textarea><br><br>
<button type="submit">Submit</button>
</form>
<div id="error-message" style="color: red;"></div>
<script>
const contactForm = document.getElementById('contactForm');
const errorMessage = document.getElementById('error-message');
contactForm.addEventListener('submit', (event) => {
if (!contactForm.name.value || !contactForm.email.value || !contactForm.subject.value || !contactForm.message.value) {
event.preventDefault(); // Prevent form submission
errorMessage.textContent = "Please fill out all fields.";
} else {
errorMessage.textContent = ""; // Clear error message
}
});
</script>
</body>
</html>