Step 1: Use the style sheet.
<Asp: textbox id = "textbox1" runat = "server" style = "ime-mode: Disabled" onkeydown = "mykeydown ()"> </ASP: textbox>
Step 2 Use JS scripts.
<SCRIPT type = "text/JavaScript">
Function mykeydown ()
{
VaR K = Window. event. keycode;
If (k = 46) | (k = 8) | (k = 189) | (k = 109) | (k = 190) | (k = 110) | (k> = 48 & K <= 57) | (k> = 96 & K <= 105) | (k> = 37 & K <= 40 ))
{
}
Else if (k = 13)
{
Window. event. keycode = 9;
}
Else
{
Window. event. returnvalue = false;
}
}
</SCRIPT>
You can use a style sheet (style = "ime-mode: Disabled") to prevent switching to a Chinese character input method. That is to say, you can only use an English input method. This prevents Chinese characters from being entered.
JavaScript scripts are used to restrict keyboard input. Only numbers, decimal points, minus signs, backspace keys, deletion keys, and direction keys can be entered.
ASCII code description:
8: Return key
46: Delete
37-40: direction keys
48-57: number in the keypad
96-105: Number of the primary key area
110, 190: decimal point in the keypad and primary key areas
189 and 109: negative numbers in the keypad and primary key areas
13: Press ENTER
9: tab is the stuff that moves the focus to the next text box.
By the way, there are two disadvantages:
1. if multiple decimal points are not verified.
2. Multiple negative signs are not verified, and the symbols must be in the front.