-4

I have a form like this

<div>
     <input type="text" data-identity-td="uk-021">
     <input type="text" data-identity-td="ae-033">
     <input type="text" data-identity-td="fr-045">
     <input type="text" data-identity-td="in-125">
</div>

if i type anything any of the textbox eg: if i type something in third text box the

data-identity-td="fr-045" after click the outside of the text box need to get a message

"You typed something in fr-045"

any jquery solution for this?

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Muhammad ali
  • 287
  • 4
  • 17
  • A simple `blur` event handler …? – CBroe Jan 29 '18 at 08:46
  • I'd suggest you read the jQuery documentation, as even just a basic glance through the method names would probably give you enough information about what you need to do: http://api.jquery.com – Rory McCrossan Jan 29 '18 at 08:48

1 Answers1

0

You can use simple JQuery to achieve this. You need to use focusout event:

$('input').on('focusout', function(){
  $('.message').text('You typed something in ' + $(this).data('identity-td'))
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  <input type="text" data-identity-td="uk-021">
  <input type="text" data-identity-td="ae-033">
  <input type="text" data-identity-td="fr-045">
  <input type="text" data-identity-td="in-125">
</div>
<div class='message'></div>
Milan Chheda
  • 8,159
  • 3
  • 20
  • 35
  • 1
    Possible caveat though - this shows the 'you typed something' message even if you just click on an input, then off it again – Rory McCrossan Jan 29 '18 at 08:49