PDA

View Full Version : Field validation


trice
11-03-2002, 07:07 PM
I have a form with four fields. Fields A, B, C, and D. I need validation that if any of the fields a,b or c has a value then field d needs to have a value. If feld d has a value but a,b or c is blank then I need an alert.

I have tried various ways of doing this but I can't get anything to work.

Can someone please point me in the right direction?

Thanks in advance.
Trice

dsdemmin
11-03-2002, 07:33 PM
if (document.form1.a.value != "" || document.form1.b.value != "" || document.form1.c.value != "" && document.form1.d.value == "") {
alert ("Please enter value for d");
document.form1.d.focus ( );
return false;
}
elseif (document.form1.a.value == "" && document.form1.b.value == "" && document.form1.c.value == "" && document.form1d.value != "") {
alert ("Please remove value for d");
document.form1.d.focus ( );
return false;
}
}

Good luck.