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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -