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

JS restricts the input box (all commonly used ones)_javascript skills

WBOY
Release: 2016-05-16 17:27:49
Original
1493 people have browsed it

1. The text box can only enter numeric codes (decimal points cannot be entered)

Copy code The code is as follows:



2. Only numbers can be entered, decimal points can be entered.
Copy code The code is as follows :




3. Number and decimal point method two
Copy code The code is as follows:



4. Only letters and Chinese characters can be entered
Copy code The code is as follows:

< input onkeyup="value=value.replace(/[d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[d]/g, ''))" maxlength=10 name="Numbers">

5. Only English letters and numbers can be entered, Chinese cannot be entered
Copy code The code is as follows:



6. Only numbers and English can be enteredchun
Copy the code The code is as follows:


7. There can only be up to two digits after the decimal point (numbers and Chinese can be entered). Letters and arithmetic symbols cannot be entered:
Copy code The code is as follows:



8. There can only be up to two digits after the decimal point (numbers, letters, Chinese) (can be input), you can input operation symbols:
Copy code The code is as follows:


//Only Chinese characters can be input:

//Only numbers can be entered:

//Only English and numbers can be entered:

//The control input box can only input text or numbers, or it does not allow the input of special characters
//The following characters are not allowed to be entered here: (like!@#$%^&*, etc.)