Kemik Posted July 19, 2007 Share Posted July 19, 2007 Hello all, Can anyone explain why my form won't allow "Test Title" without the " to pass through? I originally thought it was the space, but it doesn't allow "TestTitle" either. <?php /* Ensure title is alphanumeric */ else if(!eregi("^([0-9a-z]\.\' \-)+$", $subtitle)){ $form->setError($field, "* Title not alphanumeric"); } ?> The above code is part of a range of checks, however as the form is giving me this error I can only presume it's because of this area of code. Edit: I taken the part of code from a username check (the code above is to check the title of a news post). You can see the original code below... <?php /* Check if username is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); } ?> Link to comment https://forums.phpfreaks.com/topic/60807-solved-eregi-form-problem/ Share on other sites More sharing options...
hackerkts Posted July 19, 2007 Share Posted July 19, 2007 What letter you wanna allow user to put? Take note of your [0-9a-z], it only allows small letter but not capital. So it should be [0-9a-zA-Z], or simply just use this else if(!eregi("^([a-zA-Z0-9\.\' ]+)$", $subtitle)){ Link to comment https://forums.phpfreaks.com/topic/60807-solved-eregi-form-problem/#findComment-302586 Share on other sites More sharing options...
Kemik Posted July 19, 2007 Author Share Posted July 19, 2007 That's weird. My username allows Capital letters. I want to allow . - ' and spaces in my news title but that code I supplied will only allow alum single words. Link to comment https://forums.phpfreaks.com/topic/60807-solved-eregi-form-problem/#findComment-302598 Share on other sites More sharing options...
Kemik Posted July 19, 2007 Author Share Posted July 19, 2007 I've tried adding A-Z however it still doesn't work. <?php /* Ensure title is alphanumeric */ else if(!eregi("^([0-9a-zA-Z\.\' \-]\.\' )+$", $subtitle)){ $form->setError($field, "* Title not alphanumeric"); } ?> EDIT: I removed \.\' after the ] and it now works... I think. Thanks. Link to comment https://forums.phpfreaks.com/topic/60807-solved-eregi-form-problem/#findComment-302652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.