Home > Web Front-end > JS Tutorial > js restricts input tags to Chinese only_javascript skills

js restricts input tags to Chinese only_javascript skills

WBOY
Release: 2016-05-16 15:52:23
Original
1518 people have browsed it

The method is very simple, I won’t go into detail here, I’ll just give you an example

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>只能输入中文</title>
</head>
<body>
<input type="text" id="text" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
</body>
</html>
Copy after login

The above is the entire content of this article, I hope you all like it.

Related labels:
js
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