|
A little help on some Javascript
Ok, I have been trying to make a php file cancel submitting the data the user enters when two pieces of information are the same using javascript. As far as I know, what I have tried should be working fine but the form keeps on submitting. Here is what I have:
javascript:
<script type="text/javascript">
function validateForm()
{
var Team1=document.getElementById("Team1").value;
var Team2=document.getElementById("Team2").value;
var Team3=document.getElementById("Team3").value;
if (Team1 != Team2) && (Team1 != Team3) && (Team2 != Team3)
{
return true;
} else {
alert('Choose 3 different Teams for the Match!');
return false;
}
}
</script>
HTML/PHP that is used to submit the match by activating another PHP file that submits the match to a database:
<input type="submit" value="Add/Update" style="margin: 0 auto" formaction="MatchTable.php" onsubmit="return validateForm();">
If anyone could help me on this, it would be really awesome.
|