In JS I used this code:
if(string.match(/[^A-Za-z0-9]+/))
but I don\'t know, how to do it in PHP.
You can use preg_match() function for example.
if (preg_match('/[^A-Za-z0-9]+/', $str)) { // ok... }