spfoonnewb Posted July 17, 2007 Share Posted July 17, 2007 I am trying to validate a string for just numbers and letters... I can't seem to get it working. Not much of a fan of regex.. 0-9, A-Z, a-z <?php //This doesn't work.... if (eregi("/^[a-z0-9]+$/i", "test")) { echo "Valid"; } else { echo "Invalid"; } ?> Link to comment https://forums.phpfreaks.com/topic/60420-solved-form-validation-this-should-work/ Share on other sites More sharing options...
sKunKbad Posted July 17, 2007 Share Posted July 17, 2007 <?php if (eregi("^[a-z0-9]+$", "test")) { echo "Valid"; } else { echo "Invalid"; } ?> Link to comment https://forums.phpfreaks.com/topic/60420-solved-form-validation-this-should-work/#findComment-300557 Share on other sites More sharing options...
spfoonnewb Posted July 17, 2007 Author Share Posted July 17, 2007 <?php if (eregi("^[a-z0-9]+$", "test")) { echo "Valid"; } else { echo "Invalid"; } ?> Thanks, that worked.. simple enough. Link to comment https://forums.phpfreaks.com/topic/60420-solved-form-validation-this-should-work/#findComment-300560 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.