Hello,

Im quite new to javascript and php, so dont flame me too hard

Could someone take a look at my code and tell me what am i doing wrong for form validation? I was able to get it to work with on click function but failing with the example below. I have a form with options to pick from and php that submits the values to mysql. All i need is for some of the forms to be validated before the values are entered into database, right now the form is entered into db and no warning saying that fields are empty comes up. Any help is much appreciated.


thanks!
Sofia


<HEAD>
<script type="text/javascript">
function ValidateForm(form)
{

if (IsEmpty(form.Nationality))
{
alert('You have not entered an account number')
form.Nationality.focus();
return false;
}


if (!IsNumeric(form.Nationality.value))
{
alert('Please enter only numbers or decimal points in the account field')
form.Nationality.focus();
return false;
}

return true;

}

</script>
</HEAD>

<BODY>
<form name="form" method="post" onsubmit="return ValidateForm(this)">
<div><select name="Nationality">
<option value=""></option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
</select>


<?php
if (isset($_REQUEST['submit'])) {
$sql = "INSERT INTO $db_table(Nationality, Country) values ('".mysql_real_escape_string(stripslashes($_REQUEST['Nationality']))."',,'".mysql_real_escape_string(stripslashes($_REQUEST['Country']))."')";
if($result = mysql_query($sql ,$db)) {
echo '<h1>Success!</h1><br><br>';
} else {
echo "ERROR: ".mysql_error();
}
} else {
?>


<input type="submit" name="submit" value="Submit">
</form>
</BODY>