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!

0

2 Answers 2

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)?

Sign up to request clarification or add additional context in comments.

1 Comment

.keyup is great, now that I think about it. Thanks!
0

Maybe with keypress no ?

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

Documentation here -> keypress

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.