Does anyone know why this javascript isn't working ? Its returning the field is empty when its not
The html i'm using on the form is:
onsubmit="return validate_form ( );" method="post" name="AddPTR"
And the javascript is:
<script type="text/javascript">
function validate_form ( )
{
valid = true;
if ( document.forms.AddPTR.PTR2.value == "" )
{
alert ( "Please fill in the PTR box." );
valid = false;
}
return valid;
}
</script>
document.forms.AddPTR.PTR2.value. Also when declaring a local variable in javascript it is a good practice to put avar. Sovar valid = true;. This avoids polluting the global scope.