[英]jQuery - How to check if input contains only cyrillic letters
I don't know how i can check if input with specific id contains only cyrillic letters in it. 我不知道如何检查具有特定ID的输入中是否仅包含西里尔字母。
I want simple jQuery function to check the input for cyrillic letters and when there are only cyrillic letters to give alert Everything is COOL :D
and when there are not only cyrillic letters to give alert We've got a problem Houston!
我想要简单的jQuery函数来检查输入的西里尔字母,并且只有西里尔字母可以发出警报
Everything is COOL :D
并且不仅有西里尔字母可以发出警报We've got a problem Houston!
. 。
This is a simple example of what i want to do this function. 这是我要执行此功能的简单示例。
Can you please help me out ? 你能帮我吗?
Thanks in advance! 提前致谢!
You can use regexp like: 您可以像这样使用regexp:
/[а-яА-Я]/
Here is an example: 这是一个例子:
var str1 = "Привет";
var str2 = "Hello";
var patt = /[а-яА-Я]/g;
console.log( patt.test(str1) );
// will log true
console.log( patt.test(str2) );
// will log false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.