Reputation: 3488
In addition to serverside validation I want to have some clientside validation (javascript/jquery) for an input field accepting 'unicode letters' http://www.regular-expressions.info/unicode.html#category ... of course there are numerous tutorials/examples out there ... but still I can't get it work ... that's what I tried so far:
//this is working:
var re_username = /^[a-zA-Z]+$/;
//this is not working:
var re_username = /^[p{L}]+$/;
var re_username = /^[p{L}]+$/u;
var re_username = /[p{L}]+$/u;
var re_username = /[p{L}]*$/u;
var re_username = /[p{L}]+$/u;
var re_username = /[\p{L}]+$/u;
var re_username = /^[\p{L}]+$/u;
var re_username = /[\p{L}\p{M}]*+;
var re_username = /[\p{L}\p{M}]*+$;
var re_username = /^\p{L}+$/;
var re_username = /^[\p{L}\p{M}]+$/;
//here I further take the val ...
var is_username = re_username.test($('#chatusername').val());
Is p{L} not working like that in javascript/jquery?
Upvotes: 0
Views: 56
Reputation: 1074355
JavaScript's built-in regular expression engine doesn't have support for Unicode categories. Steven Levithan's XRegExp
does, though, you could use that.
var re_username = XRegExp("^\\pL+$");
Without using a library, you have to include ranges in a character class for all the code points that are letters according to Unicode.
Upvotes: 1