How to track event to add text to the input?

Create a form, it is necessary that when entering text in input is triggered a function, that when you enter, if you remove text, no action should occur. How it can be implemented? Thanks in advance for your help.
April 19th 20 at 12:39
3 answers
April 19th 20 at 12:41
if you remove text, no action should happen

that is, do not delete the text, or what?
The text is removed, but the function is not executed - marley.Brekke26 commented on April 19th 20 at 12:44
April 19th 20 at 12:43
Maybe try:

$( ".target" ).change(function() {

Here you can read:
April 19th 20 at 12:45
so, 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('added text');

Find more questions by tags ReactjQueryJavaScript