x
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Validation Example</title>
</head>
<body>
<form onsubmit="return validateForm()">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Submit</button>
</form>
<script>
function validateForm() {
var email = document.getElementById("email").value;
if (email === "") {
window.alert("Please enter your email.");
return false; // Prevent form submission
}
return true; // Allow form submission
}
</script>
</body>
</html>