Manual input is prohibited for Textbox, but swipe card input is allowed

Source: Internet
Author: User

Preliminary Idea: textbox. readonly = true; but in this way, even card swiping input will be disabled.

The second idea is to determine whether the keyboard is input or the user swiping the card, but how to determine whether the keyboard input should trigger a keydown event or the like. The result is the same as the trigger.

The third idea-roundabout: because the card number is a card number of a specific length, it can be entered to a specific length in a short period of time, and the user input must be at least 4 S. It can be determined by this time to determine whether to manually input or swipe the card.

 

I used a timer control to debug its attribute internal to 200 ms

CodeAs follows:

 

Code

    Private     Void  Timereffectick (  Object Sender, eventargs E)
{
If (Textboxx1.text. Length ! = Textboxx1.maxlength)
{ // Check whether the text box content length is equal to the maximum length at a specified time
Timer1.enabled = False ;
Textboxx1.text = "" ;

}
}

Private Void Textboxx1_previewkeydown ( Object Sender, previewkeydowneventargs E)
{ // When entering content in the text box, this event in the text box is triggered first.
Timer1.enabled = True ;
}

 

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.