Last active
December 12, 2015 02:18
-
-
Save sajanp/4697418 to your computer and use it in GitHub Desktop.
CodeIgnitor form validation class to allow only alphanum and spaces. My regex is ABSOLUTELY terrible (whose isn't?), so...this may not work and needs to be tested. If you find that the regex pattern needs to be tweaked, please come back and edit this gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function alpha_num_spaces($subject) | |
{ | |
$pattern = "#^[A-Z0-9 ]+$#i"; | |
$res = preg_match($pattern, $subject); | |
if ($res == 1) | |
{ | |
return TRUE; | |
} | |
else | |
{ | |
return FALSE; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment