Welcome to the Linux community forum. You can only enter the number 19functiontest_shuzi (strshuzi) {20varmyReg ^ [0-9] * $; 21if (myReg. test (strshuzi) returntrue; 22 returnfalse; 23} 24 can only input 25functiontest_han
Welcome to the Linux community forum and interact with 2 million technical staff> enter 18 // you can only enter the number 19 function test_shuzi (strshuzi) {20 var myReg =/^ [0-9] * $/; 21 if (myReg. test (strshuzi) return true; 22 return false; 23} 24 // only 25 Chinese characters can be entered. function test_han
Welcome to the Linux community forum and interact with 2 million technicians>
18
// Only numbers can be entered
19
Function test_shuzi (strshuzi ){
20
Var myReg =/^ [0-9] * $ /;
21
If (myReg. test (strshuzi) return true;
22
Return false;
23
}
24
// Only Chinese characters can be entered
25
Function test_hanzi (strhanzi ){
26
Var myReg =/^ [\ u4e00-\ u9fa5] {0,} $ /;
27
If (myReg. test (strhanzi) return true;
28
Return false;
29
}
30
Script
31
32
33
37
38
[1] [2]