0

Still trying to get my head around some simple javascript issues the following works in php but not in javascript can someone point me in the right direction obviously my code is wrong.

if((dobyear==false) && (dobmonth==false) && (dobday==true))
{
return 'noyearmonth';
}

thanks

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by fxm
0

What are dobyear,dobmonth,dobday? Are they set to be boolean values or are you trying to see if they have a value at all? If they are not boolean values you might try:

if(!dobyear && !dobmonth && dobday)
{
return 'noyearmonth';
}

You can also do it as:

if(dobyear == null && dobmonth == null && dobday != null)
{
return 'noyearmonth';
}
0

first way works fine

Yes, but does that make any sense?
An error is returned only when: dobday exists and BOTH dobyear and dobmonth are absent.
I suspect that you really want: dobday exists and EITHER dobyear or dobmonth is absent.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.