JS judges that only numbers and decimal points are allowed. only numeric code can be entered in the text box (decimal point cannot be entered) <input onkeyup = "this. value = this. value. replace (/\ D/g, '')" onafterpaste = "this. value = this. value. replace (/\ D/g, '')"> 2. only numbers are allowed, and decimal points are allowed. <input onkeyup = "if (isNaN (value) execCommand ('undo ')" onafterpaste = "if (isNaN (value) execCommand ('undo ') "> <input name = txt1 onchange =" if (/\ D /. test (this. value) {alert ('only numbers allowed '); this. value = '';}"> 3. method 2: Number and decimal point <input type = text t_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 + (?: \. \ 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 + (?: \. \ 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 Chinese characters can be entered <input onkeyup = "value = value. replace (/[\ d]/g, '')" onbeforepaste = "clipboardData. setData ('text', clipboardData. getData ('text '). replace (/[\ d]/g, '')" maxlength = 10 name = "Numbers"> 5. you can only enter English letters and numbers, but cannot enter Chinese <input onkeyup = "value = value. replace (/[^ \ w \. \/]/Ig, '')"> 6. only numbers and English <font color = "Red"> chun </font> <input onKeyUp = "value = value. replace (/[^ \ d | chun]/g, '')"> 7. A maximum of two digits (numbers and Chinese characters) can be entered after the decimal point. Letters and operator numbers cannot be entered: <input onKeyPress = "if (event. keyCode <48 | event. keyCode> 57) & event. keyCode! = 46 | /\. \ d $ /. test (value) event. returnValue = false "> 8. only two digits (numbers, letters, and Chinese characters) can be entered after the decimal point. You can enter the operator number: <input onkeyup = "this. value = this. value. replace (/^ (\-) * (\ d + )\. (\ d ). * $/, '$1 $2. $3 ') "> it can only be a number or a decimal point, plus or minus onkeypress =" return event. keyCode> = 4 & event. keyCode <= 57"