I want to be able to make sure the name input text field AND either the email input OR the phone number input is also filled in before being allowed to submit the page. I'm trying to do so at the moment with an if statement but have not been successful. Here is my code:
function check()
{
if (document.getElementById("name").value=="" && (document.getElementById("email").value=="" || document.getElementById("phone").value==""));
{
alert("Please Enter Your Name and either your Email or Phone number");
return false;
}
return true;
}
But the alert pops up even when every form is filled with information? Any help would be appreciated. Also here is the html:
<form name="textFields" id="textFields" action="http://www.google.com" method="POST">
<div>
<label for="firstname"><b>Name:</b></label>
<input type ="text" name ="firstName" id="name"><br>
</div>
<div>
<label for ="email"><b>Email:</b></label>
<input type ="text" name ="email" id="email"><br>
</div>
<div>
<label for="phone"><b>Phone:</b></label>
<input type ="email" name ="phone" id="phone"><br>
</div>
Aucun commentaire:
Enregistrer un commentaire