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! Link to comment https://forums.phpfreaks.com/topic/144917-solved-validate-minimum-of-numbers-in-a-test-filed/ 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/144917-solved-validate-minimum-of-numbers-in-a-test-filed/#findComment-760440 Share on other sites More sharing options...
phpretard Posted February 12, 2009 Author Share Posted February 12, 2009 Thank you! Link to comment https://forums.phpfreaks.com/topic/144917-solved-validate-minimum-of-numbers-in-a-test-filed/#findComment-760442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.