Check if field only contains alphanumerics (no spaces or special chars)

  • Thread starter Thread starter account8226
  • Start date Start date
A

account8226

Guest
Hello,

I am trying to validate one of my fields. In my datawritter I am calling a validating function, that call a method 'validate' in my model.

PHP:
if (preg_match('/[^a-zA-Z0-9_]/', $username)) return false;

Why is that not working ? It's always returning false...
 
Solved it, was just passing out the wrong variable ;) This preg match function works.
 
Top Bottom