i think my problem is simple to solve but i am a beginner to javascript but not coding.
[code]<script type=”text/javascript”>
<!–
function validateanswer(form)
{
if (form.answer.value == “”)
{ alert (“Please enter an answer!”);
form.answer.focus();
return false;
}
return true;
}
//–>
</script>
So here is my javascript code between the head tags. this should alert me if my ‘answer’ field is empty. simple enough but it doesnt.
[code] onsubmit=”return validateanswer(form);”
I have this in my <form> tag before the >. so on submit the script should run. ok. my form action takes me to another page. does that matter? I dont think it does.
What is wrong here?
form.answer.value, the word ‘form’ here does this have to resemble my form name? I took this coding from a book but it doesnt seem to work. the alert doesnt execute.
I have some php code in the file however it doesnt interfere.
yes i do have js enabled.
thanks in advance. help me debug.