JS Event Intercept Enter button page Submit Event sample code

Source: Internet
Author: User

This article is mainly to the JS Event Interception enter Button page submission event sample code is introduced, the need for friends can come to the reference, I hope to help you

If you press Enter in a text box to let him execute a JS function, but do not want to submit the form, you can do this:

function Ysearch ()///Year text box return key Reload DataWindow

{

Validateinputtext (' yyyy ');//Want to do the first JS function

if (event.keycode==13)

{

Changeym ()//Want to do the second JS function, finished to empty the event

event.returnvalue=false;//the event to intercept, the form can not get event.keycode==13

}

}

  

runat= "Server" class= "CRBT_INPUT1" >

  

Hint, if in an event, you want to call two JS functions, such as the Validateinputtext (' yyyy ') called in the onkeydown event; and Changeym () function, then you can write them both in a function ysearch (), and then call the Total function Ysearch ().

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.