logical operators - Min and Maxium Age Comparison jQuery -
hi i'm new php , need make validation if customer age bracket doesn't satisfy filter disable question lets say
customer age bracket = 40 -44 question age bracket = 18-75
so customer still in bracket , should allowed take question. let's
minquesage = 18; maxquesage = 75; mincusage = 40; maxcusage = 44;
i have
if(parseint(mincusage) >= parseint(minquesage) && parseint(maxcusage) <= parseint(maxquesage)) { console.log("need disable"); }
why still got need disable? condition correct?
your conditions when age valid, need invert condition disabling. can invert condition !
operator.
if(!(parseint(mincusage) >= parseint(minquesage) && parseint(maxcusage) <= parseint(maxquesage))) { console.log("need disable"); }
you can use demorgan's law invert parts of condition.
if(parseint(mincusage) < parseint(minquesage) || parseint(maxcusage) > parseint(maxquesage)) { console.log("need disable"); }
Comments
Post a Comment