dde Posted January 11, 2015 Share Posted January 11, 2015 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)))) Link to comment https://forums.phpfreaks.com/topic/293834-filter_validate/ Share on other sites More sharing options...
Frank_b Posted January 11, 2015 Share Posted January 11, 2015 you wrote option instead of options 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)); 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! Link to comment https://forums.phpfreaks.com/topic/293834-filter_validate/#findComment-1502506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.