Home  >  Article  >  Web Front-end  >  Summary of js character type methods for controlling text box input_javascript skills

Summary of js character type methods for controlling text box input_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:53:581267browse

JS control text box can only input numbers

Copy code The code is as follows:


JS control text box can only input numbers and decimal points

Copy code The code is as follows:

Copy code The code is as follows:


JS control text box can only input English and numbers

Copy code The code is as follows:


JS control text box can only input Chinese

Copy code The code is as follows:


JS control text box can only input Chinese, English and numbers

Copy code The code is as follows:


The JS control text box can only input Chinese, English, numbers, and spaces

Copy code The code is as follows:


The JS control text box can only input Chinese, English, numbers, and decimal points

Copy code The code is as follows:


In summary:

First enter

in ‘

onkeyup="value=value.replace(/[^X]/g,'')"

Then replace the X in (/[X]/g,'') with the code you want to enter,

Chinese u4E00-u9FA5, numbers 0-9, English a-zA-Z, other symbols @, dot or other symbols.

You can also have more than one, just separate them.

For example: Chinese and English numbers @symbol dot symbol a-zA-Z0-9u4E00-u9FA5@.

If you want to not be able to right-click the pop-up menu in the text box and paste the copied information

Just enter onpaste="return false" oncontextmenu="return false;" in ''

Statement:
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