View Single Post
  #1 (permalink)  
Old Jul 24th, 2007, 22:39
stacioanri stacioanri is offline
New Member
Join Date: Jul 2007
Location: Belgrade
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unicode Regular Expression won't work ??

HEEEELP ME!

I can't make javascript to validate username form field with unicode characters (charset=utf-8).

PHP that works well on server side:

$legalChars = "/\p{L}|\p{Pc}|\p{N}/"; // allow letters, numbers and underscores
$legalCharsCount = preg_match_all($legalChars,$strng,$blb);
...

JavaScript that drives me crasy:

var error = "";
var illegalChars = /\p{L} \p{Nd}/; //I tried also: / :Lu | :N / and similar expressions without result.
if (illegalChars.test(strng)) { //tried also .match and .seach combinations
error = "The username contains illegal characters.\n";
}

Is ther anyone out-there to know what it is all about ??

Many thanks in advance.
Reply With Quote