Integer: < ASP: textbox ID = Rel_level Borderwidth = "0px" Runat = "Server" Onkeyup = "If (event. keycode! = 37 & event. keycode! = 39) value = value. Replace (/\ D/g ,'');" Height = "18px" Width = "55px" > </ ASP: textbox >
Data:
< ASP: textbox 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"
ID = "Tbxwork_time" 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 }"
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; javascript: Stat (this. Value );"
Runat = "Server" > </ ASP: textbox > Code
< ASP: textbox ID = "Tbxbudmoney" Width = "80px" Runat = "Server" Style = "Font-size: 9pt; Border: 1px solid #003390; font-style: normal ;" Onkeyup = "Clearnonum (this )" Onchange = "Clearnonum (this )" > </ ASP: textbox >
// The limit can only contain numbers.
Function clearnonum (OBJ)
{
OBJ. value = obj. value. Replace (/[^ \ D.]/g, ""); // leave the non-numeric and point empty
OBJ. value = obj. value. Replace (/^ \./g, ""); // the first digit of the warranty is not a point
OBJ. value = obj. value. Replace (/\. {2,}/g, "."); // there is only one. No more.
OBJ. value = obj. value. replace (". "," $ # $ "). replace (/\. /g ,""). replace ("$ # $ ",". "); // warranty. only once, but not more than twice
// The following warranty can have only two small numbers
VaR curvalue = obj. value;
If (curvalue. lastindexof ('.')> = 0)
{
If (curvalue. Split ('.') [1]. length> 2)
{
Curvalue = curvalue. substr (0, curvalue. lastindexof ('.') + 3 );
OBJ. value = curvalue;
}
}
}