Function istridecimal (value ){
If (value! = NULL & value! = ''){
VaR decimalindex = value. indexof ('.');
If (decimalindex = '-1 '){
Return false;
} Else {
VaR decimalpart = value. substring (decimalindex + 1, value. Length );
If (decimalpart. length> 2 ){
Return true;
} Else {
Return false;
}
}
}
Return false;
} <SPAN class = hilite1> input </span> name = "sumadjust" type = "text" id = "sumadjust" size = "20" value = '<C: out value = "$ {form1.sumadjust}"/> 'onkeyup = "If (isnan (value) | istridecimal (value) Execcommand ('undo ') "onafterpaste =" If (isnan (value) | istridecimal (value) Execcommand ('undo ') "/>
Function istridecimal (value ){
If (value! = NULL & value! = ''){
VaR decimalindex = value. indexof ('.');
If (decimalindex = '-1 '){
Return false;
} Else {
VaR decimalpart = value. substring (decimalindex + 1, value. Length );
If (decimalpart. length> 2 ){
Return true;
} Else {
Return false;
}
}
}
Return false;
}
<SPAN class = hilite1> input </span> name = "sumadjust" type = "text" id = "sumadjust" size = "20" value = '<C: out value = "$ {form1.sumadjust}"/>'
Onkeyup = "If (isnan (value) | istridecimal (value) Execcommand ('undo ')"
Onafterpaste = "If (isnan (value) | istridecimal (value) Execcommand ('undo ')"
/>
Function istridecimal (value ){
If (value! = NULL & value! = ''){
VaR decimalindex = value. indexof ('.');
If (decimalindex = '-1 '){
Return false;
} Else {
VaR decimalpart = value. substring (decimalindex + 1, value. Length );
If (decimalpart. length> 2 ){
Return true;
} Else {
Return false;
}
}
}
Return false;
}
<Input name = "sumadjust" type = "text" id = "sumadjust" size = "20" value = '<C: Out value = "$ {form1.sumadjust}"/>'
Onkeyup = "If (isnan (value) | istridecimal (value) Execcommand ('undo ')"
Onafterpaste = "If (isnan (value) | istridecimal (value) Execcommand ('undo ')"
/> 1. 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 can be entered, and decimal points can be entered.
<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. Number and decimal point method 2
<Input type = text tvalue = "" ovalue = "" onkeypress = "If (! This. value. Match (/^ [\ + \-]? \ D *? \.? \ D *? $/) This. value = This. t_value; else this. tvalue = This. value; If (this. value. Match (/^ (? : [\ + \-]? \ D + (? : \. \ D + )?)? $/) This. ovalue = This. Value "onkeyup =" If (! This. value. Match (/^ [\ + \-]? \ D *? \.? \ D *? $/) This. value = This. t_value; else this. tvalue = This. value; If (this. value. Match (/^ (? : [\ + \-]? \ D + (? : \. \ D + )?)? $/) This. ovalue = 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. ovalue = 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. Only English letters and numbers are allowed. Chinese characters are not allowed.
<Input onkeyup = "value = value. Replace (/[^ \ W \. \/]/ig,'') ">
6. Only numbers and English letters can be entered. <font color = "red"> Chun </font>
<Input onkeyup = "value = value. Replace (/[^ \ d | Chun]/g,'') ">
7. After the decimal point, you can enter a maximum of two digits (numbers and Chinese characters). You cannot enter letters or operator numbers:
<Input onkeypress = "If (event. keycode <48 | event. keycode> 57) & event. keycode! = 46 |/\. \ D $/. Test (value) event. returnvalue = false ">
8. A maximum of 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') ">
9. Only Chinese characters can be entered:
<Input name = "realname" type = "text" maxlength = "20" class = "input_style" value = "<% = realname %>" onkeyup = "value = value. replace (/[^ \ u4e00-\ u9fa5]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ u4e00-\ u9fa5]/g, '')"/>