开发者

Regex-expression with danish characters

开发者 https://www.devze.com 2022-12-23 15:50 出处:网络
I\'m currently trying to wrap my head around regex, I have a validation snippet th开发者_StackOverflowat tests an input box against a regex-expression:

I'm currently trying to wrap my head around regex, I have a validation snippet th开发者_StackOverflowat tests an input box against a regex-expression:

$.validator.addMethod("customerName", function(value, element){
return (/^[a-zA-Z]*$/).test(value);
}, "Some text");

That works well, but when I try to add a space and some special danish characters, it doesn't filter the danish characters, only the space.

$.validator.addMethod("customerName", function(value, element){
return (/^[a-zA-Z æøåÆØÅ]*$/).test(value);
}, "Some text");

Any ideas to what could be wrong?


Could it be a difference in character encoding, i.e. UTF-8 vs 8859-1?

0

精彩评论

暂无评论...
验证码 换一张
取 消