<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Form</title>
<style>
form {
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
}
label, input {
margin-bottom: 10px;
display: block;
}
input[type="text"],
input[type="email"] {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
</head>
<body>
<form id="myForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<input type="submit" value="Submit">
</form>
<script>
document.getElementById('myForm').onsubmit = function(e) {
e.preventDefault(); // Prevent form submission
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
alert("Name: " + name + "\nEmail: " + email); // Simple alert displaying form data
};
</script>
</body>
</html>