This article introduces how to use JavaScript to restrict the input box: the text box can only enter numbers and code, only numbers, only letters and Chinese characters, only English letters and numbers, and many more, if you are interested, you can learn 1. only numeric code can be entered in the text box (decimal point cannot be entered) 
 
 The Code is as follows:
 
 
 
 
2. Only numbers can be entered, and decimal points can be entered. 
 
 The Code is as follows:
 
 
 
 
 
3. Number and decimal point method 2 
 
 The Code is as follows:
 
 
 
 
4. Only letters and Chinese characters can be entered 
 
 The Code is as follows:
 
 
 
 
5. Only English letters and numbers are allowed. Chinese characters are not allowed. 
 
 The Code is as follows:
 
 
 
 
6. Only numbers and English chun numbers can be entered. 
 
 The Code is as follows:
 
 
 
 
7. After the decimal point, you can enter a maximum of two digits (numbers and Chinese characters). You cannot enter letters or operator numbers: 
 
 The Code is as follows:
 
 
 
 
8. A maximum of two digits (numbers, letters, and Chinese characters) can be entered after the decimal point. You can enter the operator number: 
 
 The Code is as follows:
 
 
 
// Only Chinese characters can be entered:
 
// Only numbers can be entered:
 
// Only English and numbers can be entered:
 
// You can enter only text or numbers or special characters in the control input box.
// The following characters cannot be entered! @ # $ % ^)
 
 
// Only spaces are allowed.
Onkeyup = "value = value. replace (/\ s/g ,'')"
// Only Chinese and English characters can be entered:
Onkeyup = "value = value. replace (/[^ \ a-zA-Z \ u4E00-\ u9FA5]/g, '')" onbeforepaste = "clipboardData. setData ('text', clipboardData. getData ('text '). replace (/[^ \ a-zA-Z \ u4E00-\ u9FA5]/g ,''))"