0

I would like to fire a function when the user changes the value of the text box. Not when they click on it (Like onfocus, .focus or .change) but when they edit the content from the pre-filled value.

HTML:

<input id="formloginpassword" type="text" name="pass" placeholder="Password" value="filled-from-backend"></input>

Thanks!

Chase
  • 29,019
  • 1
  • 49
  • 48
GiantDuck
  • 1,086
  • 3
  • 14
  • 27

2 Answers2

2

You could try keyup, keydown or keypress:

​$("input").on("keyup", function(){
    console.log($(this).val())
});​

EXAMPLE

Look here for more details about the 3 events: What's the theory behind jQuery keypress, keydown, keyup black magic (on Macs)?

Community
  • 1
  • 1
Chase
  • 29,019
  • 1
  • 49
  • 48
0

Maybe with keypress no ?

$("#formloginpassword").keypress(function() {
   alert("Handler for .keypress() called.");
});

Documentation here -> keypress

Cedrun
  • 457
  • 2
  • 8