phpretard Posted February 12, 2009 Share Posted February 12, 2009 I have a text field that is allowed numbers and text but it should contain at least 7 numbers. This is how I would validate for 7 number only but I need at least 7 numbers and text optional. <? if (($var=='')||(strlen($var) < 7)||(!is_numeric($var))){ $message="Missing Numbers"; } ?> Thank you! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 12, 2009 Share Posted February 12, 2009 <?php if (strlen(preg_replace('/[^\d]/','',$var)) < 7){ $message="Must have at least 7 numbers"; } ?> Quote Link to comment Share on other sites More sharing options...
phpretard Posted February 12, 2009 Author Share Posted February 12, 2009 Thank you! 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.