L
L
LazariusPaskalius2020-04-18 10:51:17
JavaScript
LazariusPaskalius, 2020-04-18 10:51:17

How to track the event of adding text to input?

I create a form, it is necessary that when entering text in the input, the function works, it is when entering, when deleting the text, no actions should occur. How can this be implemented? Thank you in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stepan Davashenevquestion, 2020-04-18
@LazariusPaskalius

like this, in principle, to increase the number of characters

var start_length = $( ".target" ).val().length;
$( ".target" ).keyup(function() {
  if($( ".target" ).val().length > start_lenght) {
     start_length = $( ".target" ).val().length;
     alert('добавлен текст');
  }
});

H
hzzzzl, 2020-04-18
@hzzzzl

no action should be taken when deleting text

that is, you can’t delete the text at all, or how is it?

S
struggler, 2020-04-18
@struggler

Maybe try this:

$( ".target" ).change(function() {
  //
});

You can read here: https://ruseller.com/jquery.php?id=154

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question