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"; } ?> Quote 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"; } ?> Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.