I've got a preg_match in PHP that is working. It attempts to check a value for non-US keyboard characters:
Code PHP:if( preg_match( '/[^\x20-\x3B\x3D\x3F-\x7E\s]/', $value ) ) { // ... }
So, this is working. If I put foreign chars in $value, it definitely finds a match. JS on the other hand, not working with the same regex:
Code JavaScript:var regex = /[^\x20-\x3B\x3D\x3F-\x7E\s]/; if( this.value.search(regex) != '-1' ){ // ... }
Since I don't read or speak any foreign languages, I use charset restriction to keep spam from going through my forms, but I want to detect it client side if possible. Any help is appreciated.



Reply With Quote
Bookmarks