user2533777
user2533777

Reputation:

jquery detect if input area is not empty while user is typing

I have a small jquery code which hide/show an icon when an input field is empty/have something My code is:

$("#pass1").on("change",function(){
  if($("#pass1").val())
      $("#showpass").show();
  else
  $("#showpass").hide();

});

But this occures only when user finish typing and moves to next field or removes focus but I want to do this while user is typing i.e it should occur as soon as user either enters or delete an single character.How can I do this ?

Upvotes: 1

Views: 816

Answers (1)

Kiran
Kiran

Reputation: 20313

Use .keyup(). Try this:

$('#pass1').keyup(function() {
    //your code goes here
});

Upvotes: 2

Related Questions