Js event intercepts the sample code for the enter key page submission event

  • 2020-03-30 02:13:48
  • OfStack

If you press enter in a text box to ask it to execute a js function, but you don't want to submit the form, you can do this:

Function ysearch() // year text box return key reload the DataWindow
{
      ValidateInputText (' yyyy); // the first js function I want to do
      If (event. The keyCode = = 13)
      {
              Changeym (); // the second js function I want to do, I'll clean up the event when I'm done
              Event. The returnValue = false; // if the event event is intercepted, the form will not get the event.keycode ==13
      }
}


< Asp: TextBox ID = "txtYear MaxLength =" 4 "&" have spent Onkeydown = "ysearch ();"                                                                
Runat = "server" class = "CRBT_input1 >"
< / asp: TextBox>
// prompt, if you want to call two js functions in one event, such as validateInputText('yyyy') in the onkeydown event; And changeym (); The ysearch() function, in which case you can write both of them in a function called ysearch(), and then call the total function ysearch()


Related articles: