function validateForm() {
if (document.getElementById('name').value = "") {
alert('Name field is required!');
document.getElementById('name').focus();
return false;
} else if (document.getElementById('email').value = "") {
alert("Email field is required!");
document.getElementById('email').focus();
return false;
} else if (document.getElementById('password1').value != document.getElementById('password2').value) {
alert("Passwords have to match!");
return false;
}
return true;
}
HTML :
<form id="form1" method="post" onsubmit="return validateForm()" action="success.html">
Why is it always returning true, even if one of these fields are empty?