Web Programming 1 Unit 3
Web Programming 1 Unit 3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Contact Us</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 50px auto;
background: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 25px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: 600;
}
input[type="text"],
input[type="email"],
textarea,
select {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
box-sizing: border-box;
}
textarea {
resize: vertical;
height: 100px;
}
.radio-group {
margin-bottom: 20px;
}
.radio-group label {
font-weight: normal;
margin-right: 15px;
}
input[type="submit"] {
background-color: #007BFF;
color: #fff;
border: none;
padding: 12px 20px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
width: 100%;
transition: background-color 0.3s ease;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
if (!emailPattern.test(email)) {
alert("Please enter a valid email address.");
return false;
}
if (!phonePattern.test(phone)) {
alert("Phone number must be exactly 10 digits.");
return false;
}
return true;
}
</script>
</head>
<body>
<div class="container">
<h2>Contact Us</h2>
<form name="contactForm" method="POST" action="submit.php" onsubmit="return
validateForm();">
<label for="name">Name:</label>
<input type="text" name="name" id="name" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" required>
</form>
</div>
</body>
</html>
Reference:
MDN Web Docs. (2023, November 17). How the web works - Learn web development.
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/
How_the_Web_works. Content available under a Creative Commons license.
Output: