From: jr on
Something is not working on the validation script. The bu is
required in a search form. Zonenm and zoneid are required together.
If someone searches on a bu and also a zoneid, then they must also
search on the zonenm and vice versa.So it is either all 3 or just the
bu. The bu validation always works. HOwever if I search on bu and
zoneid for example, I get a message asking for zonenm, but
alternatively, if I ask for the zoneid and bu, it should ask for the
zonenm. I tried it with the 3rd else if as an else instead of else if
but then I got a syntax error. thanks,
<script type="text/javascript">
function checkscript() {
var ele = document.forms[0].elements;
if (!ele.search_bu.value) {
alert('The Business Unit is a required field!');
return false;
} else if (ele.search_zoneid.value && !ele.search_zonenm.value) {
alert('Zone ID but no zone number');
return false;

} else if(ele.search_zonenm.value && !ele.search_zoneid.value) {
alert('Zone Number but no zone id');
return false;
}
return true;
}
</script>



From: David Mark on
On Jul 29, 12:50 am, jr <jlro...(a)yahoo.com> wrote:
> Something is not working on the  validation script.  The bu is
> required in a search form.  Zonenm and zoneid are required together.
> If someone searches on a bu and also a zoneid, then they must also
> search on the zonenm and vice versa.So it is either all 3 or just the
> bu.  The bu validation always works.  HOwever if I search on bu and
> zoneid for example, I get a message asking for zonenm, but
> alternatively, if I ask for the zoneid and bu, it should ask for the
> zonenm.  I tried it with the 3rd else if as an else instead of else if
> but then I got a syntax error.  thanks,
> <script type="text/javascript">
>  function checkscript() {
>     var ele = document.forms[0].elements;
>     if (!ele.search_bu.value) {
>         alert('The Business Unit is a required field!');
>         return false;
>     } else if (ele.search_zoneid.value && !ele.search_zonenm.value) {
>         alert('Zone ID but no zone number');
>         return false;
>
>     } else if(ele.search_zonenm.value && !ele.search_zoneid.value) {
>         alert('Zone Number but no zone id');
>         return false;
>     }
>     return true;
>  }
>  </script>

Why use else's at all? Each conditional branch returns after all. ;)
From: SAM on
Le 7/29/10 6:50 AM, jr a �crit :
> Something is not working on the validation script. The bu is
> required in a search form. Zonenm and zoneid are required together.

aren't you too tired to always ask the same thing ?

can't you think by yourself ?

if ( bu.value ) {
if ( zoneid.value && !zonenum.value ) { blah 1 }
else
if ( !zoneid.value && zonenum.value ) { blah 2 }
}
else { blah 0 }

the "blah"s must return false


--
sm
From: Denis McMahon on
On 29/07/10 05:50, jr wrote:

> Something is not working on the validation script. ...
> but then I got a syntax error. thanks,

What was the error message, and what line in the script did it identify?

Rgds

Denis McMahon
From: jr on
On Jul 29, 10:30 am, Denis McMahon <denis.m.f.mcma...(a)googlemail.com>
wrote:
> On 29/07/10 05:50, jr wrote:
>
> > Something is not working on the validation script. ...
> > but then I got a syntax error.  thanks,
>
> What was the error message, and what line in the script did it identify?
>
> Rgds
>
> Denis McMahon

There wasn't an error message but the user could perform the search
incorrectly. It is an enforced business rule to search only on both.