Abstract: [JavaScript] [ASP.NET] TextBox can only enter the next numbers and decimal place
Before brother did let a user can only enter numbers with the Enter key (2012/11 / a 22 to join a decimal point)
http://www.dotblogs.com.tw/aquarius6913/archive/2012/11/17/83979.aspx
But there are users wrote to say, you can run but you can enter the normal Chinese
So brother changed a bit .... as follows:
PS:
This will lock the focus is in English mode, you can not fight Chinese
In which the Style is effective under the IE browser used, allows the user to input method can not be used in this text box.
1. Only enter numbers
function ValidateNumber(e, pnumber)
{
if (!/^d+[.]?[1-9]?$/.test(pnumber))
{
var newValue = /^d+/.exec(e.value);
if (newValue != null)
{
e.value = newValue;
}
else
{
e.value = "";
}
}
return false;
}
2. You can only enter digital + one decimal place
Y2J's Life:http://kimenyeh.blogspot.tw/
Original: Large column [JavaScript] [ASP.NET] TextBox can only enter the next numbers and decimal place