简体   繁体   English

jquery 验证瑞典字符

[英]jquery validate swedish character

I'm using jquery validate plugin and extending it like that我正在使用 jquery 验证插件并像这样扩展它

jQuery.validator.addMethod("noNumeric", function(value, element) {
            return this.optional(element) || /^[a-zA-Z]+$/i.test(value);
        }, "Letters only please");

Its working fine but not valid for swedish charecter.它工作正常,但对瑞典人无效。

Which regular expression can be used to test for characters (including swedish accented ones) but which also EXCLUDES (ie does not match) special characters like commas, dollars, hashes etc?哪个正则表达式可用于测试字符(包括瑞典重音字符)但也排除(即不匹配)特殊字符,如逗号、美元、哈希等?

You should be ok to use \w meaning any character found in a word - should work in most languages:您应该可以使用\w表示在单词中找到的任何字符 - 应该适用于大多数语言:

/^\w+$/

According to regular-expressions.info javascript has no unicode support for regular expressions.根据 regular-expressions.info javascript不支持正则表达式的 unicode。 So \w will not work.所以\w将不起作用。

But you can add the special characters to your character class like但是您可以将特殊字符添加到您的角色 class 中,例如

/^[a-zA-ZäÄöÖüÜß]+$/

I used the german ones I don't no the swedish.我用的是德国的,我没有瑞典的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM