<asp:textbox id="TextBox1" runat="server"
Width="80px"></asp:textbox>
In fact, server controls can also add onkeydown and up events
In this way, you can only enter decimals and numbers
In .NET development, in order to ensure the correctness of data, users are often required to verify the content they enter, figuratively speaking, only numbers can be entered.
Start by adding a property event to the TextBox control:
<asp:textbox class="Text"
onkeypress="if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false; "
id="txtY_Revenue" style="TEXT-ALIGN: right" runat="server" Width="90%" MaxLength="12">
</asp:textbox>
The keyboard checks when pressed to see if it is 0-9, if not, does not put the current input into the text box
Note: This method controls the TextBox to enter only numbers: 0~9, providing an idea
Supplement:
1. Cancel the dotted box when the button is pressed
Add the attribute value hideFocus or HideFocus=true to the input
2. Read only the text box content
Add the attribute value readonly to the input
3. Prevent TEXT documents from being cleared back (style content can be used as a class reference)
<INPUT style=behavior:url(#default#savehistory); type=text id=oPersistInput>
4. ENTER key to move the cursor to the next input box
<input >
5. Only in Chinese (with flashing)
<input>Use the range of Ascii codes to judge
6. Only for numbers (with flashing)
<inputonbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" > use the range of the Ascii code to judge
7. Only for numbers (no flickering)
<input style="ime-mode:disabled"> use the range of Ascii code to judge
8. Only English and numbers can be entered (with flashing)
<inputonbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" > validated with js' regular expressions
9. Shield input method
<input type="text" name="url" style="ime-mode:disabled">
10. Only enter numbers, decimal points, minus (-) characters (no flashing)
<input>Use the range of Ascii codes to judge |