jardane Posted April 18, 2010 Share Posted April 18, 2010 I have an input box for a zip code and i need error code to check if it contain 5 digits and contains only numbers. Quote Link to comment Share on other sites More sharing options...
litebearer Posted April 18, 2010 Share Posted April 18, 2010 look here http://roshanbh.com.np/2008/03/usa-zip-code-format-validation-php.html Quote Link to comment Share on other sites More sharing options...
SaMike Posted April 18, 2010 Share Posted April 18, 2010 strlen returns string's length and is_numeric checks if its numeric (who knew, right?) Example: <?php $string = "51245"; if(!is_numeric($string)) exit('Numbers only lol!'); if(strlen($string) != 5)) exit('5 numbers lol!'); ?> Quote Link to comment 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.