javascript - Why this IF allow negative numbers? -


i'd know why code accept negative numbers , how correct it.

echo '<script type="text/javascript">     if (' . $_post["product_qty"] .' < 1) {         alert("atleast 1");     } else if (isnan(x)) {         alert("must input numbers");         return true;     } </script>'; 

thank you

it's accepting string. switch if this.

if(is_numeric($_post['product_qty"']) && (int) $_post['product_qty"'] < 1) 

Comments