Questions about the Submit button after the HTML control and the server control press ENTER

Source: Internet
Author: User

Today to do the project, the project is a car wash system, swipe after the focus out of the auto-trigger return event, such as, a text box, put the focus, brush the card, the text box automatically get card number, while triggering the return event, (just like a bank card), found after the page after the swipe of the button code, after the query , find two methods, method one: Change the text box to HTML control, plus Runat=server (server control does not onkeydown), plus

    1. <input type="text" id="T1" onkeydown="if (event.keycode==13) {document.getElementById (' BT ')." Click (); return false;} " /><button id="BT" onclick="alert (' Carriage return clicked button! ')" > Confirm </button> Executes the button event (button is a server control line)
    2. The second method is to continue the server control and write it in Pageload:

      Txtcode.focus ();
      TXTCODE.ATTRIBUTES.ADD ("onkeydown", "If" (Event.which | | Event.keycode) {if (Event.which = = 13) | | (Event.keycode = = 13)) {document.getElementById (' "+ Btnsearch.uniqueid +"). Click (); return false;}} else {return true}; ");

Questions about the Submit button after the HTML control and the server control press ENTER

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.