Use one field to validate values in one of two fields

M

Meredith

I am using a script to validate a form using the presence of a value in
one field and determine if there is a value in one of two fields. It
is an either/or situation. If the date rcvd field is not "", then
either the ref names has to be filled in OR the res date has to be
filled in. I have tried many combinations of this. Any suggestions
will be greatly appreciated.

<script language="JavaScript">
function ValidateForm(){

var Rcv1Field = document.form1.DateRcvd
var Refer1Field = document.form1.RefNames
var FRDfield = document.form1.ResDate

if (Rcv1Field.value != "" && (Refer1Field.value == "" || FRDfield.value
!= "")){

if (Rcv1Field.value != "" && Refer1Field.value == "" ){
alert("Please Enter a Referral")
Refer1Field.focus()
return false
}
if (Rcv1Field.value != "" && FRDfield.value != ""){
alert("Please Enter a Final Resolution Date")
FRDfield.focus()
return false
}
}
return true
}
</script>
 
M

Meredith

Thank you for your assistance....I was able to use the logic of the
suggestion to get the desired result. This is the snippet that I used:

if (Rcv1Field.value != ""){
if (Refer1Field.value == "" && FRDfield.value == ""){
alert("Please Enter a Referral Name OR a Resolution Date");
Refer1Field.focus();
return false;
}
}

The Date Rcvd field is not required, however, if it does have a date in
it, either the referral name or resolution date needs to have a value.
Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top