Run Javascript when enter pressed

Bret van Putten
   <class="searchform">
<input type="text" id="textbox" placeholder="Search..." checkbox_test(this.value);">
<input type="submit" id="button" class="classname" onClick="javascript:checkbox_test();">Search</a>

I have a custom search engine with checkbox options. I have a script called "checkbox_test" that will grab the text from the textbox and run the search query plus additional options selected with checkboxes.

The problem I have is that when I press 'Enter' nothing happens, I have tried many examples from stackoverflow and examples I found on the internet but it does not seem to work for me. Any ideas how to solve this problem?

Basically I want to run the javascript when the visitor presses enter (with and without focus)

brainbowler

You've got a markup error there. That's probably why nothing you try is happening.

Try the following:

<input type="text" id="textbox" placeholder="Search..." onkeypress="checkbox_test(this.value);">

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Run javascript function when enter is pressed - JavaScript only no Jquery

Run method when enter is pressed

Make a form run a javascript when ENTER is pressed or its button is pressed, without submitting

Javascript to trigger submit when enter is pressed

Call a javascript function when enter key is pressed

Call specific method in javascript when enter key pressed anywhere in page

Detect selected form when Enter key is pressed via jQuery or JavaScript

Javascript : Scroll to top to the div when enter key is pressed

How to set focus on next input when the button "Enter" is pressed? (javascript)

Trigger a button click with JavaScript when Enter key is pressed

html & javascript enter button redirects to error page - otherwise duplicates text to chat (only when enter is pressed)

Run a Macro in Excel 2010 using Enter Key, Whether Worksheet has Changed or Not, when Pressed in Particular Range

Editor in not showing correct line number when enter key pressed continuously in JavaScript?

Android remove focus of TextEdit when Enter is pressed

Submit a form only when 'enter' key is pressed

Disable input when enter is pressed dynamically

Submit a form when enter is pressed in a textarea in React?

Writing to a div from a form when enter is pressed

Odd RubyMine indenting when enter is pressed

Invoke a serie of actions when Enter key is pressed

Form not submitting when enter key is pressed

Perform search only when enter is pressed for UISearchController

add characters when enter button pressed

Submit a certain button when ENTER is pressed

Stop entering values into array when enter is pressed

How to show alert when enter key pressed

Java Scanner not accepting input when enter pressed

Move + Submit Input when enter is pressed

When Enter is pressed Ok Button should be clicked