Muhammad Russel Muhammad Russel - 1 year ago 192
HTML Question

javascript autoclick with condition

I want to make a form where if someone type the word

in the input field, the button will be auto clicked. How can this be done?

<input type="text" id="text"><br><br>

<a href="#" id="autoclick">
<input type="button" value="type ok">

Answer Source

Try this:


<input type="text" id="text"><br><br>
<input type="button" id="button" value="type ok">


$('#text').on('keyup', function(){
    if($(this).val() == 'ok'){
// this block is for test
$('#button').on('click', function() {

Working example:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download