dde Posted January 11, 2015 Share Posted January 11, 2015 (edited) I can't get the min and max range for the FILTER_VALIDATE_INT to work. $subYoB = $_POST['yob']; $valYoB = array('option' => array('min_range' => 1900, 'max_range' => 2000)); if(!filter_var($subYoB, FILTER_VALIDATE_INT, $valYoB)) { echo "Not valid"; } else { echo "Valid"; } Whenever the input of $_POST['yob'] is an INT it validates even when the input is lower the min_range, and higher than the max_range. What am I doing wrong?I also tried this, without succes. if(!filter_var($subYoB, FILTER_VALIDATE_INT, array('option' => array('min_range' => 1900, 'max_range' => 2000)))) Edited January 11, 2015 by dde Quote Link to comment https://forums.phpfreaks.com/topic/293834-filter_validate/ Share on other sites More sharing options...
Solution Frank_b Posted January 11, 2015 Solution Share Posted January 11, 2015 you wrote option instead of options Quote Link to comment https://forums.phpfreaks.com/topic/293834-filter_validate/#findComment-1502504 Share on other sites More sharing options...
Barand Posted January 11, 2015 Share Posted January 11, 2015 The array key should be "options" and not "option" $valYoB = array('options' => array('min_range' => 1900, 'max_range' => 2000)); Quote Link to comment https://forums.phpfreaks.com/topic/293834-filter_validate/#findComment-1502505 Share on other sites More sharing options...
Barand Posted January 11, 2015 Share Posted January 11, 2015 SNAP! Quote Link to comment https://forums.phpfreaks.com/topic/293834-filter_validate/#findComment-1502506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.