Home > Article > Web Front-end > js event interception enter key page submission event sample code_javascript skills
If you press the enter event in a text box to let it execute a js function, but do not want to submit the form, you can do this:
function ysearch() //Reload the DataWindow after pressing the Enter key in the text box
{
validateInputText('yyyy');//The first js function you want to do
if(event. keyCode==13)
{
changeym();//The second js function I want to do, clear the event after completion
event.returnValue=false;//Intercept the event event If it is dropped, the form will not be able to obtain event.keyCode==13
}
}
//Tip, if in an event, you want to call two js functions, such as the validateInputText('yyyy'); and changeym(); functions called in the onkeydown event, then you can Write the two of them in one function ysearch(), and then call the total function ysearch()