Home  >  Article  >  Web Front-end  >  js event interception enter key page submission event sample code_javascript skills

js event interception enter key page submission event sample code_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:57:231206browse

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()

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn