howitzer Posted April 29, 2008 Share Posted April 29, 2008 Code goes like this: IF($variable<=0 and $variable>=10){echo "something"} If i enter letters for $variable,statement will be true and application will continue. How can i disable string input for $variable and use only numbers? Link to comment https://forums.phpfreaks.com/topic/103432-solved-ignore-string/ Share on other sites More sharing options...
conker87 Posted April 29, 2008 Share Posted April 29, 2008 You'd have to use javascript validation. Of course, you could also use it this way: <?php if (isnumeric($variable)) { if ($variable <= 0 && $variable >= 10) { echo "something"; } } else { echo "Not a number."; } ?> Link to comment https://forums.phpfreaks.com/topic/103432-solved-ignore-string/#findComment-529644 Share on other sites More sharing options...
howitzer Posted April 29, 2008 Author Share Posted April 29, 2008 Well i`m at work now so i wasn`t able to test it but i guess it`ll work. Link to comment https://forums.phpfreaks.com/topic/103432-solved-ignore-string/#findComment-529648 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.