Reputation: 85
I have a small search box in a content editor web part on my SharePoint site. The user inputs some text into a text box and then has to CLICK an image which serves as the submit button (clicking the image loads the javascript function onclick.)
This is pretty terrible as you cannot press enter to search.
Is there any way to set up the image or onClick() so that it detects Enter being pressed, like a normal submit button?
Thanks for any help
Upvotes: 2
Views: 1223
Reputation: 19014
For onclick()
no, it is not, but you can use onkeyup()
:
yourTextField.onkeyup=function(){
if(event.keyCode==13){
//enter pressed!
}
}
Upvotes: 2