Event on the tab and clicking on the next field

I have 3 text fields for example

<input type="text" name="t1" id="t1" />
<input type="text" name="t2" id="t3" />
<input type="text" name="t3" id="t3" />

after entering text in a text field, when I click on a tab or click on the next input field, I want to warn the contents of the previous text field

after entering the contents in the field t1, if I press Tab / click the next field, I should see the contents of the notification windowt1

I tried the keyup event, but it shows a warning every time I press a key.

what is the appropriate jquery method for this ???

+3
source share
1 answer

Try to use . blur () in this context,

$('[name^="t"]').blur(function(){
  alert($(this).val());
});

Demo

You can also use . focusout () ,

$('[name^="t"]').focusout(function(){
  alert($(this).val());
});

Demo i

+4