Control the small bug of the edit box control by pressing the buttons

Source: Internet
Author: User
First, send a method. The function is to return the Boolean Type by controlling the keycode of the keyboard.

<SCRIPT type = "text/JavaScript">
Function checkints (EVT)
{
If (EVT. keycode >=96 & EVT. keycode <= 105) |
(EVT. keycode >=48 & EVT. keycode <= 57) |
EVT. keycode = 8 | EVT. keycode = 37 |
EVT. keycode = 38 | EVT. keycode = 39 |
EVT. keycode = 40 | EVT. keycode = 13 | EVT. keycode = 46)
{
Return true;
}
Else
{
Return false;
}
}
</SCRIPT>

In the edit box, you can use onkeydown = "Return checkints (event)" to control whether the corresponding characters can be entered. In this case, no other illegal characters can be entered in the edit box, results During the test, the Microsoft input method is harmful. Observe the differences between the Microsoft input method and other input methods in character input, and cancel the input control method, perform regular expression verification on the control.

However, I thought about it carefully later. If it was based on the original design, it would not work for the customer to get there.

Write this article so that you can come up with a better method. If you don't have it, don't waste your time. Don't be as clever as me and think that you don't have to perform verification if you control the input.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.