I have a form with 2 textboxes. I want to check that at least one textbox is filled, and if there is only one filled do some stuff and if there are both filled do something else. I found a javascript function that I think might help me but I don't know from where to call it.
here is the function
function verification() {
var1= document.getElementById("form").value;
var2= document.getElementById("form").value;
if((var1 != "") && (var2 != ""))
{
// do what ever you want here.
}
else
{
alert("Fill at least one field");
}
}
and the form:
<form id="form" action="start.php" method="post" enctype="multipart/form-data">
Person 1: <input type="text" name="person1" /> <br/>
Person 2: <input type="text" name="person2" /> <br />
<input type="submit" value="Submit" name="Submit" />
</form>