JS can only be judged by numbers and decimal points.
1. Text box can only enter a numeric code (the decimal point can not be entered)
<onkeyup= "This.value=this.value.replace (/\d/g, ')" onafterpaste = "This.value=this.value.replace (/\d/g, ')">
2. Only the number can be entered and the decimal point will be lost.
<onkeyup= "if (IsNaN (value)) ExecCommand (' Undo ')" onafterpaste= "If (IsNaN (value)) ExecCommand (' Undo ') "><name onchange= "if (/\d/.test (this.value)) {alert (' can only enter a number '); this.value= ';}" >
3. Number and decimal method two
<inputtype=textT_value=""O_value=""onkeypress= "if (!this.value.match (/^[\+\-]?\d*?\.? \d*?$/)) This.value=this.t_value;else this.t_value=this.value;if (This.value.match (?: [/^ (?: \. \d+)?)? $/)) This.o_value=this.value "onkeyup= "if (!this.value.match (/^[\+\-]?\d*?\.? \d*?$/)) This.value=this.t_value;else this.t_value=this.value;if (This.value.match (?: [/^ (?: \. \d+)?)? $/)) This.o_value=this.value "onblur= "If" (!this.value.match (?: [\+\-]?\d+ (?: \). \d+)? | \.\d*?)? $/) this.value=this.o_value;else{if (This.value.match (/^\.\d+$/)) this.value=0+this.value;if (This.value.match (/^ \.$/)) This.value=0;this.o_value=this.value} ">
4. Only letters and kanji can be entered
<onkeyup= "Value=value.replace (/[\d]/g, ')"onbeforepaste= " Clipboarddata.setdata (' Text ', Clipboarddata.getdata (' text '). Replace (/[\d]/g, ') " maxlength name= "Numbers">
5. Only English letters and numbers can be entered, not Chinese
<onkeyup= "Value=value.replace (/[^\w\.\/]/ig, ')">
6. Only enter numbers and English <font color= "Red" >chun</font>
<onKeyUp= "Value=value.replace (/[^\d|chun]/g, ')">
7. Only a maximum of two digits after the decimal point (numeric, Chinese can be entered), can not enter letters and operation symbols:
<onKeyPress= "if ((event.keycode<48 | | event.keycode>57) && event.keycode!=46 | | /\.\d\d$/.test (value)) Event.returnvalue=false ">
8. Only a maximum of two digits after the decimal point (numbers, letters, Chinese can be entered), you can enter the operation symbol
<onkeyup= "This.value=this.value.replace (/^ (\-) * (\d+) \. ( \d\d). *$/, ' $1$2.$3 ') ">
9. Enter Chinese
<type= "text" onkeyup= "This.value=this.value.replace (/[^\u4e00-\ U9fa5]/g, ')'>
10. Enter the number:
<type= "text" onkeyup= "This.value=this.value.replace (/\d/ G, ')'>
11. Enter English
<type= "text" onkeyup= "This.value=this.value.replace (/[^a-za-z]/ G, ')'>
12. Triad
<onkeyup= "Value=value.replace (/[^\w\u4e00-\u9fa5]/g, ')">
13. Enter only numbers and letters
<class maxLength size name ID= "username" onKeyUp= "Value=value.replace (/[\w]/g, ')" >
14. In addition to English punctuation marks other people can be Chinese, English alphabet, numerals, Chinese punctuation
<type= "text" onkeyup= "This.value=this.value.replace (/^[^[email protected]#$%^&* ()-=+]/g, ') '>
HTML5 Iput Limit input