Form Field Validation not working - TechRepublic
General discussion
May 21, 2002 at 06:33 PM
krausejs

Form Field Validation not working

by krausejs . Updated 24 years ago

I am trying to implement a field validation function:

function validate()
{
var result = true;
var field=document.problem_form.explanation.value;
if ((x==null) || (x.length==0))
{
alert(“Please enter an explanation”);
result = false;
}
return result;
}

Now if the field is empty, it will display the alert window, but it will also perform the FORM ACTION. I can’t figure out why. Is there some special situation that will make it perform the ACTION that I just happen to be in? Anyadvice would be great.

Thanks,
Jeff Krause

This discussion is locked

All Comments