Home > Web Front-end > JS Tutorial > body text

通过正则表达式实现表单验证是否为中文_javascript技巧

WBOY
Release: 2016-05-16 16:59:41
Original
1201 people have browsed it

JavaScript表单验证是否为中文,判断一个输入量是否为中文,通过正则表达式实现。

复制代码 代码如下:

// 检查是否为中文
function isChn(str){
var reg = /^[u4E00-u9FA5]+$/;
if(!reg.test(str)){
return false;
}
return true;
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!