Jangga
Junior Member
- Aug 8, 2016
- 196
- 11
I know it isn't fool proof to use regex in username field however, I am using the regex below. I still think it isn't foolproof. I just had to stop all special chars..... But I really want to allow users to use hyphen & fullstop if they prefer. It seems ucweb adds space to username field automatically (this is also a problem). I used trim func in php but no way.... Someone pls edit this code below
if (preg_match('/[^\dA-Za-z\-\@\*\(\)\?\!\~\_\=\[\]]+/', $username))
{ echo "wrong inputs"; }
if (preg_match('/[^\dA-Za-z\-\@\*\(\)\?\!\~\_\=\[\]]+/', $username))
{ echo "wrong inputs"; }