Copy Code code as follows:
<input type= "text" onkeyup= "This.value=this.value.replace (/[^\.\d]/g,"); if (This.value.split ('. '). LENGTH>2) {this.value=this.value.split ('. ') [0]+ '.] +this.value.split ('. ') [1]} " >
1. Text box can only enter a numeric code (decimal point can not enter)
Copy Code code as follows:
<inputōnkeyup= "This.value=this.value.replace (/\d/g, '") "ōnafterpaste=" This.value=this.value.replace (/\D/g, ') ' >
2. Only numbers can be entered and the decimal point may be lost.
Copy Code code as follows:
<inputōnkeyup= ' if (isNaN (value)) ExecCommand (' Undo ') ' ōnafterpaste= ' if (isNaN (value)) ExecCommand (' Undo ') >
<input name=txt1ōnchange= "if (/\d/.test (this.value)) {alert (' can only enter a number '); this.value= ';} ' >
3. Number and decimal method two
Copy Code code as follows:
<input type=text t_value= "" o_value= "" ōnkeypress= "if!this.value.match (/^[\+\-]?\d*?\.? \d*?$/)) this.value=this.t_value;elsethis.t_value=this.value;if (This.value.match/^ (?: [\+\-]?\d+ (?: \. \d+)? $/)) This.o_value=this.value "ōnkeyup=" if (!this.value.match/^[\+\-]?\d*?\.? \d*?$/)) this.value=this.t_value;elsethis.t_value=this.value;if (This.value.match/^ (?: [\+\-]?\d+ (?: \. \d+)? $/)) This.o_value=this.value "ōnblur=" if (!this.value.match (?: [/^ (?: \. \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 characters can be entered
Copy Code code as follows:
<inputōnkeyup= "Value=value.replace (/[\d]/g, '") "onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[\d]/g, ' ")" maxlength=10 name= "Numbers" >
5. Can only enter English letters and numbers, can not enter Chinese
Copy Code code as follows:
<inputōnkeyup= "Value=value.replace (/[^\w\.\/]/ig,") ">
6. Only numbers and English can be entered
Copy Code code as follows:
<inputōnkeyup= "Value=value.replace (/[^\d|chun]/g,") ">
7. Only a maximum of two digits after the decimal point (number, Chinese can be entered), can not enter letters and operational symbols:
Copy Code code as follows:
<inputōnkeypress= "If" (event.keycode<48 | | event.keycode>57) &&event.keycode!=46 | | /\.\d\d$/.test (value)) Event.returnvalue=false ">
8. After the decimal point can only have up to two digits (numbers, letters, Chinese can be entered), you can enter operational symbols:
Copy Code code as follows:
<inputōnkeyup= "This.value=this.value.replace (/^ (\-) * (\d+) \. ( \d\d). *$/, ' $1$2.$3 ') >