I have a little validation code that checks that fields are filled in. It sort of works, but the most important part fails.
the code:
function checkform(my_form)
{
var problem=false;
if(my_form.colno.value=="")
{
alert("There is no collection number!");
my_form.colno.value="please enter";
my_from.colno.focus();
problem=true;
}//collection
if(my_form.Pay.value=="pay")
{
alert("this is a paid collection");
}
if(my_form.amt.value=="")
{
alert("There is no amount");
my_form.amt.value="please enter";
my_form.amt.focus();
problem=true;
}
if (problem)
{return false;}//yes problem
else
{return true;} //no problem
}//function
If there is a problem, the processing of the form is supposed to halt and go back to the form. The problem I am having is I get the alerts, but then the page goes and processes to the next page.
why doesn't the function return false like it is supposed to?
Is the answer painfully obvious that I am missing?
NB, I am doing similar checks on the server side too, I just wanted to do a little client side checking first.