Alexander Hein
Alexander Hein

Reputation: 990

How to fire a input change automatically?

The<input type="text"> submit the entry after a click outside of it.

How can I submit the input automatically?

<input type="text" name="sQuantity" id="sQuantity" value="1" onchange="onChangeInput()" onblur="onBlurInput()">

My try:

$( "#sQuantity" ).change(function() {
  $( "body" ).click(); 
});

Upvotes: 1

Views: 41

Answers (2)

Eric G
Eric G

Reputation: 2617

Use keyup or keydown

$( "#sQuantity" ).keyup(function() {
    $( "body" ).click(); 
});

You can also use onKeyup instead of onChange on the input as well.

<input type="text" name="sQuantity" id="sQuantity" value="1" onKeyup="onChangeInput()">

And here is some info on keyup and how it works https://api.jquery.com/keyup/

Upvotes: 2

sbouaked
sbouaked

Reputation: 980

you can use keyup event like this :

<input id="sQuantity" onchange="onChangeInput();"  value="1" type="text"
onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();  onblur="onBlurInput()""/>

Upvotes: 0

Related Questions