The restriction input program for the contents of a text box. This frame can only enter numbers and decimal points, who help me to change, can only enter lowercase letters and decimal points, and colon, forward and backward slash (:./)
Only digits and decimal points can be entered
| The code is as follows |
Copy Code |
| var reg =/^d*.? d{0,2}$/ |
There are several numbers at the beginning, with 0 or one decimal points in the middle, ending with 0 to 2 digits.
You can only enter lowercase English letters and decimal points, and colons, positive and negative slashes (:./)
| The code is as follows |
Copy Code |
var reg =/[a-z./\:]+/; |
A-Z includes lowercase English letters,. is the decimal point,/and \ is the left and right backslash, and finally the colon. The entire composition of a character set and code can be either, and finally in addition to +,1 or more.
Instance
| code is as follows |
copy code |
| <input Name= "Vipjia" type= "text" id= "Vipjia" size= "" onkeypress= "return Reginput (this, /^d*.? d{0,2}$/, String.fromCharCode (Event.keycode)) " Onpaste =" return Reginput (this,/^d*.? d{0,2}$/, Window.clipboardData.getData (' Text ')) "ondrop=" Return Reginput (this,/^d*.?) d{0,2}$/, Event.dataTransfer.getData (' Text ')) "value=" <%=rs1 ("Vipjia")%> " |