Important Questions JavaScript
Important Questions JavaScript
Important Questions JavaScript
2. Write a JavaScript program to validate a form with a name and email field.
```javascript
function validateForm() {
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
if (name === "" || email === "") {
alert("Name and Email cannot be empty.");
} else {
alert("Form submitted.");
}
}
```